Repository navigation
feat(platform): split chat rag_search into search and list actions - #3029
Merged
Merged
Conversation
Browse questions were stuffed into the search query, where they match nothing by construction: "list all in-review tasks" tokenises to words no task title contains, so the model reworded and re-searched its way through the whole tool budget. The verb is now explicit — a required action enum, because inferring "list" from an empty query is the omission-becomes-another-operation trap. - action="search" keeps today's fan-out byte-identical (including the tasks/projects listing fallback); an optional kind narrows it to one leg, and a residue detector (en/de/fr, punctuation-aware, reusing the search stopwords) steers pure listing utterances to the list verb — any surviving noun honours the search. - action="list" browses ONE kind through the kind's existing reader with the text predicate off, behind the same role gate and scope as its search leg: tasks/projects via the listing path (which now honours numItems and returns its real cursor), conversations via a predicate-off branch (privacy predicate untouched, hasMore proven by overfetching one), documents via listForAgent, entities via their paginated queries. Task lists require a status or projectId slice; kind="web-page" is refused with a steer to the site catalog. - The envelope always carries hasMore and a kind-tagged continueCursor only when the next call can redeem it — no totalCount, and a cross-kind or hallucinated cursor is refused before touching an index. An exact repeat of a call within one turn is answered with "use the previous result"; paging is keyed apart by its cursor. - Missing action stays cheap: a query alone runs as the search it always meant, a kind alone as the list it can only mean — only the verbless empty call costs a correction round. - rag_fetch on a project ref opts into the same listing, fixing its never-true truncated flag (the fallback pinned its own 15-row cap while the flag compared against 25). - The timeline labels a list step "Listing tasks" (en/de/fr) instead of interpolating an empty query, and the chat basics docs gain the browse story in all three locales (plus the stale "knowledge base" label quote corrected to the shipped "workspace" wording). Wire cost, measured: the rag_search definition grows 2,069 to 3,804 chars (~+460 tokens per request); a board question drops from an 8-leg fan-out with embedding and rerank to one Convex query.
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Chat's
rag_searchgains a requiredactionverb:"search"(today's multi-leg retrieval, unchanged) and"list"(browse ONE kind with filters, no text match, honest paging). Board and catalog questions stop being stuffed into the search query — the named trap where "list all in-review tasks" matches nothing by construction and the model rewords its way through the tool budget.Contract
lib/chat/tools.ts): requiredactionenum, optionalquery/kind(9-value enum) /status/projectId/limit/cursor. The enum arrays are exported and shared with the executor — the previous hand-written status mirror is gone. Description rewritten (all existing test pins kept, machine-verified) with the two first-call traps spelled out: one named item is a search, a bare state question is a task list.convex/chat/assistant_tools.ts): aninvalid_argsmatrix with a copyable corrected call in every message; a residue detector (en/de/fr, punctuation-aware, reusing the search stopwords) steers pure listing utterances toaction="list"— any surviving noun honours the search; kind-narrowed search runs one leg only (corpusis native); per-turn repeat guard keyed on the resolved call including cursor, so paging is never blocked and onlyokresults register.action+ query → the search it always meant; missingaction+ kind → the list it can only mean; verbless empty call → one correction round with both examples. Keeps every legacy-shaped transcript row valid.List backends = existing readers, words off, same ACLs
search_for_chatlisting path via newlist/excludeArchivedoptional args — now honoursnumItems+ returns its real cursor; the implicit search fallback stays byte-identical (LIST_CAP 15, no cursor)listflag skips the subject/contact predicate; assignment privacy and SCAN_CAP untouched; executor overfetches limit+1 so a full page never claims completeness; no cursor ("recent only — narrowing, not paging")listForAgent(hub/team scope named honestly; offset cursor; scan warning relayed)lifecycleStatus/statusso a trashed contact or draft SKU never reads as currentkind="website"or searchEnvelope:
hasMorealways; kind-taggedcontinueCursor(task:<id>) only when redeemable — cross-kind or hallucinated cursors are refused before touching an index; no totalCount.kind="task"requires astatusorprojectIdslice; an unknown status on a list is refused (a search still drops it).Fixed on the way
rag_fetchon a project ref:truncatedcould never be true (listing pinned its own 15-row cap while the flag compared against 25). Now an explicit listing with an accurate!isDone.Searching the workspace for ""— list steps now say "Listing tasks" (newthinking.listing.*keys, en/de/fr; de-CH needs no override).docs/*/platform/chat/basics.mdquoted a label that doesn't ship ("Searching knowledge base…") — corrected to the shipped wording in all three locales, plus the browse story and the (previously undocumented) conversations kind.Cost, measured
rag_searchwire definition 2,069 → 3,804 chars; all three tools 5,127 → 6,890 ≈ +460 tokens per request (3–9% of a typical request, ×1–5 requests/turn). In exchange a board question drops from an 8-leg fan-out (embedding + vector + BM25 + rerank) to one Convex query, and the reword-loop failure mode is closed by the verb split, the repeat guard, andhasMorehonesty. History bounding already trims tool results to 12 items on later turns, so 20-row pages don't compound.Tests
Executor matrix, cursor round-trip + cross-kind refusal, repeat-guard-lets-paging-through, detector table (the five named utterances + near-misses), reader list mode (numItems/cursor/excludeArchived via convex-test), conversations privacy re-proven under
list, timeline labels (newactivity-label.test.ts), schema↔executor enum agreement. Full platform suite green (75k+); the only red in repeated full runs isaudit_logs/integrity_check.test.ts— a pre-existing load-dependent scheduler-drain flake (file untouched here, 0–5 failures varying per run, 3× standalone 17/17).Out of scope
Fourth chat tool; sandbox
rag_search(separate definition, verified no import edge);strict/input_exampleswire fields; per-domain crawled-page catalog (exists server-side, a v2 option); lifecycle/status filters on the search legs (rows are labelled instead); Anthropiccache_controlon the chat wire (noted as a separate optimization).