Conversation
Add the chat-orchestrator experiment: a single persistent per-user chat with no workspace tools that can use external MCP tools, spawn independent chats, and list or read the user's existing chats. - New chat_mode value 'orchestrator' and GET/POST /api/v2/chats/orchestrator with a deterministic per-owner chat ID so creation is idempotent. - Orchestrator turns skip workspace built-ins, workspace MCP tools, and subagent tools; they receive spawn_chat, list_chats, and read_chat. - Orchestrator chats are excluded from the chat list and reject workspace and plan mode updates. Chat.mode is exposed in the SDK. - Sidebar shows a pinned "Orchestrator" entry and /agents/orchestrator lazily creates the chat on the first message.
Contributor
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
Replace the dedicated GET/POST /chats/orchestrator handlers with two
smaller pieces: an `orchestrator` flag on CreateChatRequest and a
middleware that rewrites the literal "orchestrator" path segment to the
caller's deterministic orchestrator chat ID before ExtractChatParam.
Every existing /chats/{chat} route now works for the orchestrator.
Also regenerates docs after dropping a struct comment.
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.
Adds the
chat-orchestratorexperiment: a single persistent chat per user with no workspace tools that can use external MCP tools, spawn independent chats, and list or read the user's existing chats. When the experiment is on, the/agentssidebar shows a pinned "Orchestrator" entry above the chat list.How it works
chat_modeenum valueorchestrator. The chat ID is deterministic per owner (codersdk.OrchestratorChatID), so a concurrent create collides on the primary key instead of producing two orchestrators./chats/{chat}rewrites the literalorchestratorsegment to the caller's orchestrator chat ID beforeExtractChatParam, so every existing chat route (GET,PATCH, messages, stream, ...) works at/api/v2/chats/orchestrator/...and 404s until the chat exists. Creation isPOST /api/v2/chatswithorchestrator: true(409 if it already exists)./agents/orchestratorrenders a create form until the first message, then redirects to the chat.read_file,execute,create_workspace, ...), workspace MCP tools, and the subagent tools. They receive external MCP tools plusspawn_chat(creates an independent root chat owned by the user, which shows up in the sidebar and can create its own workspace),list_chats(owned root chats with status, summaries, workspace, paging, search), andread_chat(chat details plus latest assistant response; owner-only).GET /api/v2/chats, andPATCH/ message requests rejectworkspace_idandplan_modefor them.Chat.modeis now exposed in the SDK so the UI hides the workspace picker and plan toggle.Testing
TestOrchestratorChat(coderd): lifecycle, singleton, list exclusion, guards, tool set, andspawn_chat/list_chatsend to end against the fake model.TestOrchestratorToolsOwnershipBoundary(chatd):read_chat/list_chatsnever expose another user's chats.ChatsSidebarexperiment gating tests,chats.test.tsmutation coverage,pnpm check,pnpm lint.Left
TODO(chat-orchestrator)comments incoderd/x/chatd/ARCHITECTURE.mdfor the human author to document the new endpoint and tool set.Implementation plan
Orchestrator chat experiment
Goal
Add an experimental "Orchestrator" chat: a single persistent chat per user
that has no workspace tools but does have external MCP tools, can spawn new
chats, and can list and read the user's existing chats. It is pinned at the
top of the /agents sidebar as "Orchestrator" behind the
chat-orchestratorexperiment.Decisions
chat_modeenum valueorchestrator. Modes alreadydrive tool assembly (
explore,computer_use), so this reuses theexisting per-mode switching in
prepareGenerationandbuildSystemPrompt. "One per user" is enforced with a deterministicper-owner chat ID (
chatd.OrchestratorChatID) so concurrent createscollide on the primary key. A partial unique index was rejected: the new
enum label cannot be referenced in the migration transaction that adds
it, and an enum-to-text cast is not immutable.
initial user message, so the orchestrator is created lazily on the user's
first message via
POST /api/v2/chatswithorchestrator: true.orchestratorpath segment is rewritten to thecaller's deterministic orchestrator chat ID before
ExtractChatParam, soevery existing
/chats/{chat}/...route works for it with no dedicatedhandlers.
GET /api/v2/chats/orchestrator404s until it is created.GetChatsso they donot appear as regular sidebar rows; the sidebar renders a fixed entry.
(
read_file,execute,create_workspace, ...), no workspace MCPtools, no subagent (
spawn_agent) tools. They get external MCP tools,personal skills, the advisor (if that experiment is on), and three
orchestrator tools:
spawn_chat: creates an independent root chat owned by the user(appears in the sidebar like any other chat and can create its own
workspace).
list_chats: lists the user's root chats with status, title,summary, last turn summary, workspace, timestamps; supports search
and paging.
read_chat: returns a chat's details plus its latest assistantresponse.
chats (PATCH, messages), and
Chat.modeis exposed in the SDK so the UIcan hide the workspace picker and plan toggle.
the deployment default (which is workspace-centric).
Steps
codersdk:ExperimentChatOrchestrator,ChatModetype +Chat.Mode,CreateChatRequest.Orchestrator,OrchestratorChatAlias,OrchestratorChatID.GetOrchestratorChatByOwnerIDquery,GetChatsexclusion, dbauthz wrapper + test,
make gen.isOrchestratorMode, orchestrator tools file, tool assembly andprompt branches,
CreateChatprompt selection, guard inapplyRequestedMCPServerIDsuntouched.orchestratorflag inpostChats, alias middleware on/chats/{chat}, guards inpatchChat/postChatMessages,make gen.chatModein generated types, API client + queries,/agents/orchestratorroute + page, sidebar entry, hide workspace/plancontrols for orchestrator chats, tests.
sidebar test.
Generated by Coder Agents on behalf of @kylecarbs.