Repository navigation
feat(site/src): pick the agent type of a new chat in the composer - #189
Conversation
ResolveRootAgent resolves an agent type for a new root chat the way spawn_agent does, from the built-in general and explore types and the owner's personal, organization and project definitions. Workspace definitions are not pinned when a chat is created, so they are refused. CreateChat takes the result in CreateOptions.RootAgent. It appends the definition's prompt, sets the base type's mode, drops the orchestration guidance when the type cannot spawn, and stores a depth 0 chat_subagents row with the definition's tool policy in the insert transaction. customAgentToolPolicyOfChat now loads the policy for any chat with a row, so the policy holds for such a root from its first turn. The depth 0 row counts toward no subagent limit: every count selects children by parent_chat_id or root_chat_id.
POST /chats takes agent_type, which starts the chat as general, explore,
or a personal, organization or project agent definition, behind the
fork-agent-definitions experiment. The definition's model and reasoning
effort apply unless the request sets model_config_id or reasoning_effort.
Unknown, unreadable and workspace-only types fail with 400, and so does
agent_type without the experiment.
The chat list, GET /chats/{chat} and the created watch event report the
root's agent_type from its chat_subagents row. Roots without a row are
unchanged.
GET /api/v2/chats/fork/organizations/{organization}/agent-types lists
the built-in general and explore types and the caller's enabled
personal, readable organization and project definitions, plus the
definitions that a workspace's agent reports when workspace= is given.
Each row carries the name spawn_agent accepts, qualified the same way,
its source, description, model and base type, and whether a new root
chat can start as it, with the reason when it cannot. Workspace rows
are never root-available.
The catalog reuses the S1a resolution helpers: mergeCustomAgentTypes
for naming and rootAgentFromDefinition for root availability.
Root turns now read their tool policy with forkdb.From when fork-agent-definitions is on, so a database.Store wrapper that a turn runs through must forward ForkUnwrap and ForkWrap like dbmetrics does. Without them TestProcessChatPanicRecovery failed its turn before the first model call.
…ge-1b-root-agent-type-api
…t-usage-5-agent-types-catalog
buildTurnEnvironment decided whether to add the ACP subagent guidance from the tools before the custom agent policy filtered them, so a root or child whose policy drops acp_spawn_agent still got the guidance. It now checks the tools that the policy keeps. CreateChat also refuses a RootAgent for a chat with a parent, so a child cannot get a depth 0 chat_subagents row.
…ge-1b-root-agent-type-api
…t-usage-5-agent-types-catalog
…t-usage-5-agent-types-catalog
…ge-1b-root-agent-type-api
List computer_use when spawn_agent offers it, check project= like POST /chats, resolve definition models against the root model (new model_config_id= parameter), and report a workspace with several chat agents as an error.
…atalog' into mike/agent-usage-6-composer-picker
…n its policy Show the ACP guidance only when the policy keeps every ACP tool, drop dynamic tool names whose tools the policy removed, and leave out the create_workspace advice for a detached root that cannot create a workspace.
…ge-1b-root-agent-type-api # Conflicts: # coderd/x/chatd/fork_root_agent.go
…t-usage-5-agent-types-catalog # Conflicts: # coderd/x/chatd/fork_root_agent.go
…ge-1b-root-agent-type-api # Conflicts: # coderd/x/chatd/fork_root_agent.go
…t-usage-5-agent-types-catalog # Conflicts: # coderd/x/chatd/fork_root_agent.go
…ge-1b-root-agent-type-api # Conflicts: # docs/fork/pstack-adapter.md
|
@codex review
|
…oot-agent-type-api # Conflicts: # coderd/x/chatd/fork_root_agent.go # docs/fork/pstack-adapter.md
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…t-usage-5-agent-types-catalog # Conflicts: # docs/fork/pstack-adapter.md
…t-usage-5-agent-types-catalog # Conflicts: # docs/fork/pstack-adapter.md
…atalog' into mike/agent-usage-6-composer-picker
|
@codex review
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ent-types-catalog # Conflicts: # docs/fork/pstack-adapter.md
…atalog' into mike/agent-usage-6-composer-picker
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d8d6f4093
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7981de7998
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review
|
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged as a squash of head
|
* docs: add setup, PR, and model notes to the pstack adapter Re-check the evidence against fork main at 5ec99fb and fix the notify_user range that ran past the end of fork_notify_user.go. Add notes from the pstack e2e run: setup copies are a snapshot, execute does not read shell startup files, gh pr create can fail on a GitHub App token, the chat's PR list keeps a merged PR, and a single model config runs every pstack role. * docs: list a chat's PRs per repository and branch in the pstack adapter * docs: re-pin the pstack adapter to fork main at 1a88b7c Move the forkAgentDefinitions.ts ranges that #189 shifted by one line, and cite the agent type catalog that #189 added. * docs: add the Available agents page to the pstack adapter and re-pin its routes * docs: move the pstack adapter evidence header to fork main at b3c4911 * docs: clear stale pstack copies, use POSIX dot, and query the PR base repository * docs: add the new chat agent type picker to the pstack adapter
Part of #187 (F3, agent picker in the new-chat composer). Stacked on #188 (S2 catalog), which is stacked on #185 and #184.
#184 and #185 let
POST /chatsstart a top-level chat as an agent type, and #188 lists the types a user can use. Nothing in the UI used either yet. Behind thefork-agent-definitionsexperiment, the new-chat composer row gets an agent picker after the organization and project pickers:agent_type, so a chat starts as before.root_available: falseis disabled and shows the catalog's reason instead of its description.GET .../organizations/{organization}/agent-typeswith the composer's project, workspace and selected model (model_config_id), so it follows those pickers.agent_typeonPOST /chats. When a fresh list no longer offers the picked type, or marks it unavailable, the picker falls back to Default agent. While the list loads, the picked type is sent as is and the server rejects an unknown one with a 400.The upstream
AgentCreateForm.tsxandAgentCreatePage.tsxchanges are an import, one option, one hook call, the row condition, one render call and the request field. The picker lives in fork files (useForkAgentTypePicker,ForkCompactAgentTypeSelector). The row now also shows on a project page when the experiment is on, where it used to show only for several organizations.Tests render the real
AgentCreatePageand check the create request. One clicks the disableddeployerrow, checks that nothing changes, then picksreviewerand checksagent_type: "reviewer". The other turns the experiment off and checks that there is no picker, the list is never fetched and the chat is still created. DroppingagentTypein the form, droppingagent_typein the page, enabling the disabled row and removing the experiment gate each fail a test. Stories cover the default, a selected type, the open menu with groups and the disabled row, loading and error.Checks:
tsc,biome,oxlint,knip,lint:check,lint:compiler,lint:circular-deps, unit tests (745 in the touched dirs) and story tests (456) pass locally. In upstreamAgentCreatePage.test.tsx, 12 to 13 of 36 tests fail both on this branch and on its base, so this change does not cause them.UAT: 5/5 PASS on f080e0a (branch server built from this stack, member account, local Vite against it). The
/agentspicker lists Default agent, Built-in, Personal and Organization. The disabledcomputer_userow keeps Default agent when clicked. The project page adds the Project group. Starting a chat as a personal definition sendsagent_type, the chat reports it as a root type with its badge, and the model replies. An unknownagent_typereturns 400 and creates no chat. The catalog returns 200 on an organization with no default model. A definition whose own model is invalid can still be picked here, because the composer sends its selected model, which overrides the definition's model, asPOST /chatsdoes.