Repository navigation
Open
Labels
agent-readyMaintainer-approved for the Tale agent fleetimprovementImprovementpriority: lowLow priorityservice: platformPlatform service
Description
Summary
Since #5361 and #5364 (train 8d37319dc), a chat filed in a project answers as one of the project's agents when its owner chose one in the app, and a new chat in the app starts with the project's default chat agent. The REST chat API stayed as it was. It creates every chat with the built-in assistant and refuses an agent in the body, and its reads never say which agent answered. A send over the API to a chat whose owner chose an agent in the app answers as that agent. #5361 left these out ("Not part of this issue"); the API reference says so since 2472e545c. Part of epic #5371.
What the repository says today (train a32fb1586)
- Create: the body is strict, with
titleonly. A project chat is created withchatAgentId: null, so it answers as the assistant whatever the project's default is (services/platform/backend/rest/v1-threads.ts:591-628). - Send: every turn reads the conversation's agent from its root, sends over the API included (
services/platform/backend/domains/chat/service.ts:163-169). - Reads: a message carries
modelandproviderSlug, never the agent (v1-threads.ts:235-261). The integration lane refusesagentSlug,agentIdandprojectAgentIdon create, and checks that a thread read has noagentSlug(services/platform/backend/rest/project-agents-check.ts:458-485). - Rules: CHAT-R14 (
services/platform/backend/domains/chat/spec.md:197-207), CHAT-R41 to CHAT-R43, PROJ-R26. - Docs:
docs/en/develop/api-reference.md(the turn paragraph and "Respect thread scope and access"), and the OpenAPI descriptions inservices/platform/scripts/openapi/spec.ts.
What it means for an integration
- A script that creates a chat in a project gets the assistant. A person who starts a chat there in the app gets the project's default agent.
- A script that continues a chat a person set up in the app gets that agent's replies, and the API does not tell it so.
Constraints
- A field added to a read, or accepted on create, moves the contract fingerprint and so needs a new contract version (
services/platform/scripts/openapi/fingerprint.ts). - CHAT-R43: only a chat's owner chooses who answers, and only among the project's own agents.
- CHAT-R41: an agent's runtime, connectors, platform tools, secrets and repository access never reach a chat, whatever the door.
Options (no preference)
- Keep it as it is (documented).
- Show it: add the agent (id and name) to thread and message reads.
- Follow the project: a project chat the API creates starts with the project's default chat agent, as in the app.
- Choose it: accept an
agentIdon create, and a way to change it, checked as CHAT-R43 checks the app.
Questions
- Do integrations want the agent's instructions, or is the assistant the stable behavior scripts rely on?
- Which API key kinds (personal, team, project, organization) may choose an agent, and whose chat is it then?
Related
- feat(platform): let a project chat work with the project's agents, chosen in the chat #5361, feat(platform): a default agent for a project's chats — the first agent created unless changed #5364, Epic: projects and agents in chat — choose them, talk to them, set them up, and show generated images once #5371
- Decision: should chat start a full workspace itself, or keep handing long and repository work over to a task? #4877 (chat and an agent's workspace)
Metadata
Metadata
Assignees
Labels
agent-readyMaintainer-approved for the Tale agent fleetimprovementImprovementpriority: lowLow priorityservice: platformPlatform service
Activity
yannickmonney commentedon Nov 14, 2026
Decision
The chat API reaches full parity with the app in three steps: show who answers, then let integrations choose it, then follow the project's default. Option 1 (keep it as it is) is rejected.
Rule
agent: {id, name} | null, the agent the conversation answers as now, resolved from its root. A deleted agent or a moved chat reads correctly. Replies a project agent wrote carryagent: {id, name}from the reply's own record (its name at the time). The project read gainsdefaultChatAgent: {id, name} | null, so an integration can see what a new chat starts with.POST …/threadsandPATCH …/threads/{id}accept an optionalagentId: string | null(null = the built-in assistant). It goes through the domain's existing checks (createThread, setConversationAgent on the root), so CHAT-R43 holds unchanged: only one of the URL project's own agents is allowed. The standard agent, another project's agent, an unknown id, or any agent on an org-level chat gets 400CHAT_AGENT_INVALIDand nothing changes. setConversationAgent also refuses, inside its own transaction, an archived chat or project (CHAT-R16) and a sandbox chat (409CHAT_THREAD_NOT_DIRECT). Changing the agent mid-turn is allowed: the running turn keeps its agent, and every later turn, a queued send included, answers as the new one.agentSlugandprojectAgentIdstay refused.agentIdstarts with the project's default chat agent (PROJ-R26 / CHAT-R42), as in the app.agentId: nullpins the assistant. This changes what an unchanged request does, so it is a major contract bump, shipped in a release after "choose", whose notes announce it.Answers
agentId: nullfor the plain assistant. Only id and name are exposed.Rationale
Today the API can answer as an agent it never names and cannot control. That contradicts the premise that an API chat is the same chat as in the app. Every piece needed already exists: the effective-agent resolver, the per-reply agent record, the project-agents roster, and
CHAT_AGENT_INVALID. The new fences go into the domain function, so nothing is duplicated and no route check can race an archive. Shipping "choose" before "follow" lets integrations pin the assistant before the default changes.Implementation units (base:
main)agenton thread and message reads,defaultChatAgenton the project read, OpenAPI, minor bump, CHAT-R14/PROJ-R26 text, project-agents-check, en/de/fr docs.agentId(M, after 1): createThread/setConversationAgent with the archived, sandbox and turn rules in the domain transaction; tests for own, foreign, standard, unknown and org-level agents, null, PATCH on root, mid-turn, 404 for another user's chat, archived/sandbox refusals, and member/team/project keys; minor bump, docs, and notes announcing step 3.chatAgentId: null, major bump, retire the CHAT-R14 exception, update docs and notes.