Skip to content

refactor(coderd/x/chatd): extract subagent manager - #28758

Open
ibetitsmike wants to merge 3 commits into
mainfrom
mike/chatd-subagent-manager
Open

refactor(coderd/x/chatd): extract subagent manager#28758
ibetitsmike wants to merge 3 commits into
mainfrom
mike/chatd-subagent-manager

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

Extracts a SubagentManager that owns the child chat lifecycle in coderd/x/chatd, splitting it out of subagent.go where it was interleaved with six fantasy tools defined as large inline closures on Server.

Changes

  • New subagent_manager.go: the manager owns child chat rows, pubsub watch loops, hook dispatch points, prompt hydration, report extraction, and model listing behind Spawn, Send, Await, Interrupt, and List methods.
  • subagent.go: the six tools (task, wait_agent, message_agent, interrupt_agent, list_agents, list_subagent_models) shrink to thin adapters that map JSON arguments onto manager methods. subagent_catalog.go stays the catalog.
  • subagent_internal_test.go: lifecycle coverage moved to direct table-driven manager tests with typed assertions, replacing Server-fixture boots and raw JSON string assertions; redundant fixture matrices deleted. An e2e smoke of the task, stream, and wait_agent report round trip is retained.
  • Net diff: 1,108 insertions, 1,599 deletions (491 fewer lines) across production and tests.

Behavior

No user-visible behavior change. Spawn-time user_prompt_submit dispatch semantics (including the sibling-results commit ordering on admission failure), nested-subagent prohibition, admission pools, wait_agent error surfacing, report extraction, prompt hydration, and model selection are unchanged. resolveOrganizationModelOverride and its call sites are byte-identical to main; a parallel branch owns that block.

Testing

  • make gen (no drift), make lint, go build ./cmd/coder, and umask 022 && go test ./coderd/x/chatd/... all pass on this head; commits ran the make pre-commit hook.
  • Remote dogfood UAT passed on a real deployment: subagent spawn and streaming, parent report delivery via wait_agent, message_agent steering, interrupt_agent, list_agents, list_subagent_models, child chat page rendering, and an explicit model_config_id spawn honoring the requested model.

Xum (an AI coding agent) authored this PR on behalf of @ibetitsmike.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T13:25:29.274600Z 4d7e41e Draft marked ready
ℹ️ 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 4d7e41e503

ℹ️ 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 marked this pull request as ready for review August 29, 2026 13:21
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