Skip to content

feat(coderd/x/chatd): report stored agent types in subagent tool results - #85

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/custom-agent-types-report-type
Nov 10, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/custom-agent-types-report-type

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #7

With fork-agent-definitions on, the subagent tool results now report the child's stored agent type. Before this PR, a child spawned from a custom type such as reviewer read as "type":"general" in spawn_agent, wait_agent, message_agent, interrupt_agent and list_agents. subagentTypeFromChat derives the type from the chat mode, so it cannot know the custom name. The #69 UAT found this.

Change

  • appendForkTools wraps those five tools in storedSubagentTypeTool (fork file fork_subagent_types.go). After the upstream tool runs, the wrapper reads chat_subagents.agent_type for each chat_id in the result, including every entry of list_agents' agents, and replaces type when the stored value differs. list_agents reads all of the chat's children in one query, the new forkdb GetChatSubagentsByParentChatID, which dbauthz authorizes through the parent chat. The single-child tools use GetChatSubagentByChatID.
  • Spawn already writes the stored type: the custom name for custom types and subagentTypeFromChat for built-ins. So built-in children keep reporting general or explore.
  • Results without a type or a chat_id are left alone, and so are error results and chats without a chat_subagents row. A failed read is logged and the upstream value is kept.
  • With the experiment off, nothing is wrapped and results are unchanged. Upstream subagent.go is untouched.

Tests

  • TestForkAgentDefinitionToolResultType: spawns a workspace-tier reviewer and a general child. spawn_agent, interrupt_agent and wait_agent report reviewer, and list_agents reports reviewer and general for the two children.
  • TestForkQuerier/GetChatSubagentsByParentChatID: the new query asserts read on the parent chat.
  • Negative controls: each of these turns a test red: the tools not wrapped, the batch result dropped, or the dbauthz parent check removed.
  • Ran in Colima: go test ./coderd/x/chatd/... ./coderd/database/dbauthz/ ./coderd/database/forkdb/..., all ok on the merge with main ec6cdd6. golangci-lint found nothing in the changed files.

ARCHITECTURE.md gets a TODO for the owner to describe this.

Size

About 280 changed lines: about 55 generated (sqlc and mock), about 175 implementation and query plumbing, about 50 tests and 1 doc TODO.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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-10T00:19:34.494456Z 1d3f05a 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.

@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: 244a7d2927

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

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_subagent_types.go Resolved
@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: 1d3f05a4a6

ℹ️ 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 (8ddd673504) 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 (8ddd673504), 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 873db0e into main Nov 10, 2026
21 of 28 checks passed
@ibetitsmike
ibetitsmike deleted the mike/custom-agent-types-report-type branch November 10, 2026 00:51
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence for head 1d3f05a4a60c2d0d0d4c0988b19a74022af2d829:

  • fork-ci pull_request run 42729104780 passed; its build job checked out Merge 1d3f05a4a6 into 8ddd673504 (current main, deployed and healthy at 00:50Z). All checks green.
  • Codex review on this exact head: no major issues. 0 unresolved review threads. Merge state CLEAN.
  • UAT on this head (fresh DB, mock provider): with the experiment on, spawn_agent, wait_agent, message_agent and interrupt_agent report the stored personal or organization type, and list_agents reports all types in one batch lookup. With the experiment off, every child reports general, as upstream does.

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