Commit Graph

458 Commits

Author SHA1 Message Date
Timothy Jaeryang Baek
81781e6495 refac 2026-02-24 17:14:07 -06:00
Timothy Jaeryang Baek
3c8d658160 fix: tools_dict issue 2026-02-23 16:25:38 -06:00
Timothy Jaeryang Baek
8f49725aa5 refac 2026-02-23 12:17:36 -06:00
Timothy Jaeryang Baek
9044abf3bb chore: format 2026-02-23 01:40:53 -06:00
Timothy Jaeryang Baek
424dba443c refac 2026-02-23 01:37:06 -06:00
Timothy Jaeryang Baek
6eba27ee9c refac 2026-02-22 18:00:16 -06:00
Timothy Jaeryang Baek
8f0658e64f fix: payload tools handling 2026-02-22 17:58:59 -06:00
Timothy Jaeryang Baek
becac2b2b7 refac 2026-02-22 17:51:08 -06:00
Classic298
45e23c3ad0 perf: eliminate 2 redundant full chat deserialization on every message send (#21596)
* perf: eliminate 2 redundant full chat deserialization on every message send (#162)

Problem:
Every message send triggered get_chat_by_id_and_user_id which loads the
entire Chat row — including the potentially massive JSON blob containing
the full conversation history — even when the caller only needed a
simple yes/no ownership check or a single column value.

Two call sites in the message-send hot path were doing this:

1. main.py ownership verification: loaded the entire chat object including
   all message history JSON, then checked `if chat is None`. The JSON blob
   was immediately discarded — only the existence of the row mattered.

2. middleware.py folder check: loaded the entire chat object including all
   message history JSON, then read only `chat.folder_id` — a plain column
   on the chat table that requires zero JSON parsing.

Fix:
- Added `chat_exists_by_id_and_user_id()`: uses SQL EXISTS subquery which
  returns a boolean without loading any row data. The database can satisfy
  this from the primary key index alone.

- Added `get_chat_folder_id()`: queries only the `folder_id` column via
  `db.query(Chat.folder_id)`, which tells SQLAlchemy to SELECT only that
  single column instead of the entire row.

Both new methods preserve the same error handling semantics (return
False/None on exception) and user_id filtering (ownership check) as
the original get_chat_by_id_and_user_id.

Impact:
- Best case (typical): eliminates deserializing 2 full chat JSON blobs per
  message send. For long conversations (hundreds of messages with tool
  calls, images, file attachments), this blob can be multiple megabytes.
- Worst case: no regression — the new queries are strictly cheaper than
  the old ones (less data transferred, less Python object construction,
  no Pydantic model_validate overhead).
- The 3 remaining full chat loads in process_chat_payload (load_messages_from_db,
  add_file_context, chat_image_generation_handler) are left untouched as
  they genuinely need the full history and require separate analysis.

* Address maintainer feedback: rename method and inline call (#166)

- Rename chat_exists_by_id_and_user_id -> is_chat_owner
- Remove intermediate chat_owned variable; call is_chat_owner directly in if condition
2026-02-21 14:53:31 -06:00
Classic298
d247adb60c feat: add citation sources for fetch_url tool results (#21669)
feat: add citation sources for fetch_url tool results

URL fetches now produce clickable citation sources in the UI, matching
the existing behavior of search_web and knowledge file tools. When a
model calls fetch_url during native tool calling, the fetched URL
appears as a citable source with a content preview, giving users full
transparency into what pages the model referenced.
2026-02-21 14:49:19 -06:00
Timothy Jaeryang Baek
f1053d94c7 refac 2026-02-16 14:08:35 -06:00
Timothy Jaeryang Baek
09dc28df1e chore: format 2026-02-16 00:43:32 -06:00
Timothy Jaeryang Baek
7a7d902238 refac 2026-02-15 19:32:22 -06:00
Timothy Jaeryang Baek
f2aca781c8 refac: tool message handling 2026-02-15 16:14:47 -06:00
Timothy Jaeryang Baek
393c0071dc refac: manual skill invocation 2026-02-14 19:22:17 -06:00
Timothy Jaeryang Baek
5de60dc922 refac 2026-02-13 17:44:52 -06:00
Timothy Jaeryang Baek
3b61562c82 refac 2026-02-13 17:26:54 -06:00
Timothy Jaeryang Baek
2a11175f22 chore: format 2026-02-12 16:13:48 -06:00
Timothy Jaeryang Baek
3238d94a0e refac 2026-02-12 15:57:27 -06:00
Classic298
e8499ccdd1 fix: pass chat_id to internal task calls for consistent function context (#20585)
Ensure chat_id is reliably passed to function pipelines/manifolds during internal task invocations (web search query generation, RAG query generation, image prompt generation).

This allows stateful functions to maintain per-chat state without fragmentation, as they will now receive a consistent chat_id for all chat-scoped invocations including internal tasks.

Backend changes:
- Pass chat_id in generate_queries call for web search
- Pass chat_id in generate_queries call for RAG/retrieval
- Pass chat_id in generate_image_prompt call

Frontend changes:
- Add optional chat_id parameter to generateQueries API function
- Add optional chat_id parameter to generateAutoCompletion API function

Fixes #20563
2026-02-12 15:36:42 -06:00
Classic298
c6af296b60 add message id (#21214) 2026-02-12 15:04:27 -06:00
Thomas Rehn
390d7663b0 fix: don't pollute model text context with encoded images (#20916) 2026-02-11 18:10:22 -06:00
Classic298
ab20745ee5 Enable Rich UI embed support for action functions (#21294)
Action functions can now return HTMLResponse objects or (html, headers)
tuples with Content-Disposition: inline to render rich UI iframes in
chat, matching the existing tool behavior.

https://claude.ai/code/session_01KCZKQXj1uqgPjqjMd4U2NF

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-11 16:27:00 -06:00
Timothy Jaeryang Baek
f376d4f378 chore: format 2026-02-11 16:24:11 -06:00
Timothy Jaeryang Baek
e5035ea31e refac 2026-02-11 15:55:23 -06:00
Timothy Jaeryang Baek
c2207887b3 feat: skills backend 2026-02-11 14:00:34 -06:00
Tim Baek
aa8c2959ca refac 2026-02-09 08:07:33 +04:00
Tim Baek
b1737040a7 refac 2026-02-06 22:25:18 +04:00
Tim Baek
2c37daef86 refac 2026-02-06 03:23:37 +04:00
Timothy Jaeryang Baek
5669d1062c refac 2026-02-04 21:54:45 -06:00
Timothy Jaeryang Baek
3ace75820e refac 2026-02-04 21:46:20 -06:00
Timothy Jaeryang Baek
020cb0d4bf refac 2026-02-04 21:09:05 -06:00
Timothy Jaeryang Baek
8b75d34a8a refac 2026-02-04 21:07:30 -06:00
Timothy Jaeryang Baek
6320a9aaa9 refac 2026-02-04 20:47:21 -06:00
Tim Baek
cfd30581d5 Merge branch 'dev' into chat-message-rebased 2026-02-02 09:33:41 -06:00
Timothy Jaeryang Baek
117c091b95 refac 2026-02-01 20:07:11 -06:00
Timothy Jaeryang Baek
6ffce4bccd refac 2026-02-01 20:00:21 -06:00
Timothy Jaeryang Baek
ea9c58ea80 feat: experimental responses api support 2026-02-01 19:39:28 -06:00
Tim Baek
3da4323ef3 refac 2026-02-01 10:11:13 +04:00
Tim Baek
75e5a485d2 refac 2026-02-01 10:06:52 +04:00
Tim Baek
96f106319e refac 2026-02-01 07:59:02 +04:00
Classic298
aac98120c8 perf: batch fetch filter functions to eliminate N+1 queries (#21018) 2026-01-30 00:50:04 +04:00
Timothy Jaeryang Baek
4a55167759 refac 2026-01-26 18:04:58 +04:00
Tim Baek
6359628bc3 refac 2026-01-26 07:01:05 -05:00
Tim Baek
0dc74a8a2e refac 2026-01-23 08:33:21 -05:00
Tim Baek
90a057f400 refac 2026-01-23 08:25:19 -05:00
Tim Baek
d2c695eb11 feat: add convert_output_to_messages for OR-aligned message building 2026-01-22 19:54:05 -05:00
Timothy Jaeryang Baek
14f6747dfc refac 2026-01-22 15:07:14 +04:00
Timothy Jaeryang Baek
3c986adeda enh: kb metadata search 2026-01-09 22:21:00 +04:00
Tim Baek
daccf0713e enh: file context model setting 2026-01-09 03:41:43 -05:00