Repository navigation
Description
The report
A user asked chat about open project tasks. Chat recommended Asana, Monday.com and Jira — competitors to the product it is embedded in.
That is not a model failure. It is what the code does.
Three causes
1. rag_search has no work in it. The chat assistant's loadout is fixed at three tools (lib/chat/tools.ts), and rag_search (convex/chat/assistant_tools.ts) runs five legs: documents, crawled pages, knowledge entries, contacts, products, websites. There is no tasks leg, no projects leg, no conversations leg. A perfectly healthy knowledge base still answers nothing about the board.
2. The model does not know the product has projects or tasks. lib/chat/context.ts — the prompt assembler — contains zero occurrences of "task" or "project". The persona mentions Tasks exactly once, to push work away:
DELIVERABLES GO TO TASKS — … tell them briefly that this is task work, and to create a Task and assign it to an agent.
So the assistant is instructed to tell people to create a Task while being structurally unable to tell them whether one already exists. With retrieval empty and no product awareness, naming a competitor is the honest completion.
3. A project-bound chat does not know its own project. threads.projectId exists and is indexed, the project page has a Chats tab, and getProjectIdForThread / assertProjectAccessForChat are both built — but projectId appears nowhere in lib/chat/ or convex/chat/turn_action.ts.
Consequently projects.instructions is never read. The editor promises:
Every chat in this project starts with these instructions.
The field is validated, persisted and audited. Nothing consumes it.
Mostly a wiring gap, not a build
AGENT_TOOL_CATALOGalready shipstask_findandtask_get, overtasks/internal_queries.listTasksForAgentandgetTaskContextForAgenttasks/internal_queries.listProjectsForAgentexists with zero callersprojects/internal_queries.getProjectForInjection— "Load a project record for chat-time injection" — also has zero callers; its referenced caller was removed in the AI-backend rewrite- conversations is the one genuine build: it has queries but no agent read, and its RLS is narrower than every other leg (assignment scope, not just org + role)
A retrieval problem underneath
rag_search passes the user's raw question to every leg, and the entity backends substring-match the entire phrase (convex/contacts/query_contacts.ts and equivalents). A leg therefore asks does any row contain this whole sentence? — so legs 2–5 cannot match a question and only fire when the message is itself a name fragment. Any new leg copied from them inherits this.
Scope
- question-aware matching for the work legs — feat(platform): match questions, not just typed names, in entity search #2983
-
tasks/projects/conversationsas nameable read subjects — feat(platform): let agent read tools name tasks, projects and conversations #2984 - tasks + projects legs in
rag_search - work rows carry a
ref, andrag_fetchlearns to read one — depth for description, comments, subtasks and blockers without a fourth chat tool (see the loadout decision below) - conversations leg, honouring
passesAssignmentScopevia a predicate shared withrls_rules.tsso the two cannot drift - inject a project-bound thread's project and instructions into the prompt; retrieval still spans the user's full visibility
- migrate the existing contacts/products/entries legs onto the same matcher
Boundary
lib/chat/tools.ts states the loadout as a product decision:
Chat is for questions and retrieval … Deliverables are produced on a Task assigned to an agent.
That rationale is about execution, not retrieval. Everything here is read-only, so it honours the boundary rather than widening it.
Loadout decision
The chat loadout stays at three tools. Depth arrives on the existing rag_fetch, not as a fourth tool.
Two reasons. Every tool's schema and description ship with every turn — rag_fetch's description alone is ~10 lines — so a fourth tool taxes the overwhelming majority of turns that never need task depth (#2980 exists because that budget is actively managed). And rag_fetch is already exactly this mechanism: "Load the full text behind a ref … a search hit is only a snippet." Search returns snippets plus refs; fetch loads what is behind a ref, with offset/limit windowing. Work items should use that pattern rather than get a bespoke one.
This changes the tasks/projects legs, and the change is load-bearing. The original design gave work rows no ref, on the model of contacts and products, which cannot be fetched. Shipping it that way would leave depth genuinely unreachable — there would be no ref for rag_fetch to accept. So the legs must mint refs for task and project rows, and rag_fetch grows a work-ref branch that resolves through getTaskContextForAgent (already built, currently no chat caller).
Whatever depth returns must honour the same access gates as the leg that produced the ref: holding a ref is not a capability, exactly as filterRetrievableRagFileIds enforces for documents today. A denied work ref must read as not_found, with a message byte-identical to a nonexistent one so no existence oracle leaks.
Note for anyone reading the loadout as a hard ceiling: three tests pin the three-element list, and they exist because ask_question was built and declined. This is the second tool declined the same way — the tests are doing their job and stay untouched.
Activity
larryro commentedon Aug 18, 2026
@Israeltheminer Agree with the
rag_searchlegs for tasks, projects, and conversations — that plus prompt/product awareness is what stops chat from naming competitors when asked about the board.Keep the chat loadout at the existing three tools. Do not add
task_get(or any other new chat tool). The reported failure is empty retrieval, not missing depth;task_getalready lives on the agent catalog, and putting it on chat spends context for a case the search hits can already answer (title, status, assignee, project).If a later turn needs comments, blockers, or the full description, extend
rag_fetchto accept a work ref the search hit already returned, rather than adding a fourth tool.Israeltheminer commentedon Aug 18, 2026
Agreed — dropping the fourth-tool path and building on what exists. The scope list and a new Loadout decision section above are updated to match.
One thing worth flagging, because it would have quietly produced the outcome the fourth tool was meant to prevent: the legs as designed give work rows no
ref. The original design followed contacts and products, which carry no ref and cannot be fetched. Ship that and "extendrag_fetchto accept a work ref the search hit already returned" has nothing to accept — depth would be absent by accident rather than by decision.So the restructure is:
rag_search, and unlike contacts/products they mint arefper rowrag_fetchgrows a work-ref branch, resolving throughgetTaskContextForAgent(built, no chat caller today). Loadout stays at three.filterRetrievableRagFileIdsdoes for documents, and a denied ref answersnot_foundwith a message byte-identical to a nonexistent one, so nothing leaks by existence.app/features/chat/utils/activity-label.tsand athinking.*key per locale, plus retuningsearchingKnowledgeBase, which is wrong copy once work legs land. A work result is org state, not a citation, so it is not a source card.Unchanged: the conversations leg (still the highest-risk item, still needs
passesAssignmentScopeextracted into a predicate shared withrls_rules.ts), the project-bound thread injection, and migrating the existing contacts/products/entries legs onto the new matcher.Prerequisites #2983 and #2984 are both merged, so the legs are unblocked.
feat(platform): let chat find entities by words in a question