Skip to content

feat(site/src): pick the agent type of a new chat in the composer - #189

Merged
ibetitsmike merged 58 commits into
mainfrom
mike/agent-usage-6-composer-picker
Nov 11, 2026
Merged

ibetitsmike merged 58 commits into
mainfrom
mike/agent-usage-6-composer-picker

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

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 /chats start 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 the fork-agent-definitions experiment, the new-chat composer row gets an agent picker after the organization and project pickers:

  • Default agent is selected first and sends no agent_type, so a chat starts as before.
  • The list shows the built-in types, then groups for Personal, Organization, Project and Workspace. A type the catalog marks root_available: false is disabled and shows the catalog's reason instead of its description.
  • The list comes from GET .../organizations/{organization}/agent-types with the composer's project, workspace and selected model (model_config_id), so it follows those pickers.
  • Picking a type sends agent_type on POST /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.
  • Manage agent definitions… at the bottom of the menu opens the personal definitions page.
  • The picker is disabled while a send is pending or the composer is forbidden. The choice is not saved, so it resets on reload, as the project picker does.

The upstream AgentCreateForm.tsx and AgentCreatePage.tsx changes 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 AgentCreatePage and check the create request. One clicks the disabled deployer row, checks that nothing changes, then picks reviewer and checks agent_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. Dropping agentType in the form, dropping agent_type in 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 upstream AgentCreatePage.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 /agents picker lists Default agent, Built-in, Personal and Organization. The disabled computer_use row keeps Default agent when clicked. The project page adds the Project group. Starting a chat as a personal definition sends agent_type, the chat reports it as a root type with its badge, and the model replies. An unknown agent_type returns 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, as POST /chats does.

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.
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.
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
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

…oot-agent-type-api

# Conflicts:
#	coderd/x/chatd/fork_root_agent.go
#	docs/fork/pstack-adapter.md
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 958d83e8b8

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 39d211a2fb

ℹ️ 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".

…ent-types-catalog

# Conflicts:
#	docs/fork/pstack-adapter.md
…atalog' into mike/agent-usage-6-composer-picker
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

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".

Base automatically changed from mike/agent-usage-5-agent-types-catalog to main November 11, 2026 11:46
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

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".

@ibetitsmike
ibetitsmike merged commit 1a88b7c into main Nov 11, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as a squash of head 7981de7998 on main afb8dac5b2.

  • CI: fork-ci run 43014844129 green on the exact head, which contains main afb8dac5b2.
  • Codex: a clean receipt on 7981de7998 ("Didn't find any major issues", 12:00Z). The 3 P2 findings from the earlier pass on the same tree were dropped with reasons (refactor, cosmetic, polish). 0 unresolved threads.
  • UAT: covered by the w10-agents stack run (8/8) on the f080e0a769 superset. The later commits are review fixes covered by unit tests with negative controls. The tree is identical to the earlier verified head 0d8d6f4093.

@ibetitsmike
ibetitsmike deleted the mike/agent-usage-6-composer-picker branch November 11, 2026 12:01
ibetitsmike added a commit that referenced this pull request Nov 11, 2026
Move the forkAgentDefinitions.ts ranges that #189 shifted by one line,
and cite the agent type catalog that #189 added.
ibetitsmike added a commit that referenced this pull request Nov 11, 2026
* 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
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