Skip to content

feat(platform): split chat rag_search into search and list actions - #3029

Merged
larryro merged 1 commit into
mainfrom
feat/chat-rag-search-list-action
Aug 20, 2026
Merged

larryro merged 1 commit into
mainfrom
feat/chat-rag-search-list-action

Conversation

@larryro

@larryro larryro commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What

Chat's rag_search gains a required action verb: "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

  • Schema (lib/chat/tools.ts): required action enum, optional query / 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.
  • Executor (convex/chat/assistant_tools.ts): an invalid_args matrix with a copyable corrected call in every message; a residue detector (en/de/fr, punctuation-aware, reusing the search stopwords) steers pure listing utterances to action="list" — any surviving noun honours the search; kind-narrowed search runs one leg only (corpus is native); per-turn repeat guard keyed on the resolved call including cursor, so paging is never blocked and only ok results register.
  • Tolerance: missing action + query → the search it always meant; missing action + 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

kind backend
task / project search_for_chat listing path via new list/excludeArchived optional args — now honours numItems + returns its real cursor; the implicit search fallback stays byte-identical (LIST_CAP 15, no cursor)
conversation reader list flag 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")
document listForAgent (hub/team scope named honestly; offset cursor; scan warning relayed)
contact / product / knowledge-entry existing paginated queries with the term omitted; non-active rows carry lifecycleStatus/status so a trashed contact or draft SKU never reads as current
website summaries sliced to the page; hasMore only, no cursor
web-page refused, steered to kind="website" or search

Envelope: hasMore always; kind-tagged continueCursor (task:<id>) only when redeemable — cross-kind or hallucinated cursors are refused before touching an index; no totalCount. kind="task" requires a status or projectId slice; an unknown status on a list is refused (a search still drops it).

Fixed on the way

  • rag_fetch on a project ref: truncated could never be true (listing pinned its own 15-row cap while the flag compared against 25). Now an explicit listing with an accurate !isDone.
  • Timeline rendered queryless calls as Searching the workspace for "" — list steps now say "Listing tasks" (new thinking.listing.* keys, en/de/fr; de-CH needs no override).
  • docs/*/platform/chat/basics.md quoted 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_search wire 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, and hasMore honesty. 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 (new activity-label.test.ts), schema↔executor enum agreement. Full platform suite green (75k+); the only red in repeated full runs is audit_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_examples wire fields; per-domain crawled-page catalog (exists server-side, a v2 option); lifecycle/status filters on the search legs (rows are labelled instead); Anthropic cache_control on the chat wire (noted as a separate optimization).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant