Skip to content

feat: show a child chat's agent type behind fork-agent-definitions - #112

Merged
ibetitsmike merged 13 commits into
mainfrom
mike/custom-agent-types-r1-7-agent-type-badge
Nov 10, 2026
Merged

ibetitsmike merged 13 commits into
mainfrom
mike/custom-agent-types-r1-7-agent-type-badge

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #7

With fork-agent-definitions on, the API now reports each child chat's agent type, and the Agents page shows it as a badge next to the child's title (brief item R1.7). Before this change, the type was only visible in the subagent tool results, so a reviewer child and a general child looked the same in the sidebar and the top bar.

Change

  • codersdk.Chat gets agent_type (omitempty). It is set only on child chats and only with the experiment on.
  • GetChatSubagentTypesByChatIDs (forkdb, system-only in dbauthz) returns the type for a batch of child chats. A custom child's type is its stored chat_subagents.agent_type. A built-in child without a row gets its type from its mode, the same way subagentTypeFromChat derives it: explore, computer_use, or general.
  • fillForkChatAgentTypes (coderd/fork_chat_agent_type.go) fills the field in the chat list and GET /api/v2/chats/{chat}, including every embedded descendant. It skips the query when the response has no child chats.
  • fillForkWatchedChatAgentType fills the field on a child's created event in GET /api/v2/chats/watch. The Agents page adds a new child from that event alone, so without it a live spawn shows no badge until the next list fetch. Other event kinds never overwrite the cached field.
  • ForkAgentTypeBadge shows the type in the sidebar tree (ChatTreeNode) and the top bar (ChatTopBar). It renders nothing for general or a missing type, truncates a long custom name (the full name is in its title), and screen readers hear "Agent type: ".
  • docs/fork/pstack-adapter.md maps the field and cites the code.

With the experiment off, responses have no agent_type key and the page shows no badges.

Tests

  • TestForkChatAgentType (coderd), experiment on and off: list, root GET and child GET return reviewer for a stored custom type, general and explore for children without a row, nothing on the root, and the type on a created watch event.
  • TestForkQuerier (dbauthz) covers the new system-only query.
  • Stories ChatTopBar/WithAgentType and ChatsSidebar/ChildAgentTypes cover the badge's look, including a hidden general badge and a truncated long name. The badge has no behavior beyond rendering, so it has no Vitest test.
  • Negative controls, each restored clean: skipping the fill in the list, in the single-chat GET, and in the watch stream; dropping the experiment gate; not recursing into children; dropping the dbauthz system check; mapping explore mode to general; and an inner join that drops children without a row. Each one turns its test red. Filling roots too is an equivalent mutant, because the query already excludes roots.
  • Ran in Colima: go test ./coderd -run 'TestForkChatAgentType|TestForkChatTree|TestWatchChats' ok, go test ./coderd/database/dbauthz -run TestForkQuerier ok, go test ./coderd/database/db2sdk ok, golangci-lint reports nothing in the touched files, site tsc ok, and the AgentsPage sidebar Vitest files pass.

UAT

Ran in Colima on a slim binary of 4f92ba3cf0 with a mock provider. A member's root chat spawned a custom reviewer child, an explore child and a general child. The chat list, the root GET and each child GET reported reviewer, explore and general, and the root had no key. A WebSocket client on /api/v2/chats/watch received each child's created event with the same types. With the experiment off on the same database, no response and no new created event had the key. An earlier UAT run caught that built-in children had no type at all, which led to the mode fallback.

Size

About 420 changed lines: about 130 implementation, about 185 tests and stories, 2 doc lines, and about 100 generated lines (forkdb, mocks, metrics, API docs, Swagger and TypeScript types).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T06:27:25.884158Z 8d85a16 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 4f92ba3cf0

ℹ️ 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 posted this 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: 0b06655b58

ℹ️ 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 posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8d85a1637d

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

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (bfac64b730) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (bfac64b730), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike
ibetitsmike merged commit 5decda1 into main Nov 10, 2026
21 of 28 checks passed
@ibetitsmike
ibetitsmike deleted the mike/custom-agent-types-r1-7-agent-type-badge branch November 10, 2026 06:51
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 8d85a1637d026577b62e4e2a45b98e119f720855:

  • fork-ci pull_request run 42769695574 passed; its build job checked out Merge 8d85a1637d into bfac64b730 (current main). All checks green. Run 42768206843 had also passed on this head (agent-sdk, schema, chat-tests, build, graph, forkdb, site).
  • Codex on this exact head: no major issues (comment 6760693338). 0 unresolved review threads.
  • UAT PASS at 4f92ba3 (PR description): a member's root chat spawned a custom reviewer, an explore and a general child; the chat list, the root GET and each child GET reported those types with no key on the root, and /api/v2/chats/watch delivered each child's created event with the same type. With the experiment off, no response or event had the key. The commits after 4f92ba3 change only a db2sdk test skip entry, the badge's truncation CSS and title, story fixtures, and remove one Vitest file; no runtime behavior changes. The badge's look is covered by the ChatTopBar/WithAgentType and ChatsSidebar/ChildAgentTypes stories.

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