Repository navigation
Description
Xum created this issue on behalf of @ibetitsmike.
Part of #4.
Workspace brief from the pstack parity plan (local plan page "Running pstack on the Coder Agents Fork"; the PRD is local to Mike's Mac and not reproduced here). Claim numbers such as 1.3 or shared.2 refer to the plan page.
W2 · Nested subagents · mike/nested-subagents
Task. Let general and custom children spawn children (PRD 6.3) and make capacity configurable (R2.6).
Background. Three server checks and one UI assumption stop nesting: validateSubagentSpawnParent (subagent_catalog.go:254-262), a second copy in createChildSubagentChatWithOptions (subagent_operations.go:317-319), spawn tools only in appendRootChatTools (turn_environment.go:724, :2607), and the sidebar tree at depth 1 (chatTree.ts:40-43). Archive from the root already covers every depth: GetChatFamilyIDsByRootID uses root_chat_id (chats.sql:368). Archive of a non-root chat returns ErrArchiveRequiresRootChat (chat_mutations.go:519-521). SetArchived is allowed only from waiting and error states (chatstate/transition.go:59-76), and an interrupted chat returns to waiting only after FinishInterruption (transition.go:134-138), so interrupt then archive cannot be one transaction. Interrupt acts on one chat (chat_mutations.go:870). isSubagentDescendant (subagent_operations.go:671) lets a parent reach any descendant, which R3.3 narrows to direct children.
Scope.
- Depth: store
depthinchat_subagents; default max 2, deployment option and organization setting; the error names the limit;exploreandcomputer_usestay leaves. - Tools for non-root chats under the max depth;
list_agents,wait_agent,message_agent,interrupt_agentact on direct children (R3.3). - Interrupt cascade from any chat to its subtree, leaves first, through a forkdb
GetChatSubtreeIDsquery onparent_chat_id. Archive stays root-only, as today: it interrupts the family, waits (bounded) for every interrupt to finish, then callsSetFamilyArchived(family.go:58) once. - Capacity: organization and family caps beside the deployment defaults (
agentadmission.go:11-13; Enterprise unlockenterprise/coderd/coderd.go:226). UpstreamGetChatQueuedForCapacity(chats.sql:3205-3240, called atchatd.go:1571) counts only deployment-wide pools, so W2 adds a forkdb count query run insideAdmit(agentadmission.go:28) through the W0 transaction accessor. R3.2 live-descendant cap.list_agentsshows "waiting for capacity". - UI tree for depth above 1. R3.7 is done upstream (
chathooks/trigger.go:58-69setsParentChatIDandRootChatID): add a test for a depth-2 payload only. - After W0's question-stack merge (no wait for upstream): R8.2 descendant questions surface in the root; R8.3 secret answers.
Acceptance (PRD 6.3).
- A depth-2 family (root, coordinator, worker) completes; the worker's result reaches the root through the coordinator.
- A spawn at the limit fails with an error that names the limit.
- Archiving the root while a grandchild runs interrupts the family, then archives every member in one
SetFamilyArchivedtransaction. - Interrupting the coordinator interrupts its workers and leaves the root running.
- A child over capacity shows "waiting for capacity" in
list_agents.
Constraints. Experiment fork-nested-subagents. Keep root-first lock order. Check that memoryIndexMessage skipping children (memory.go:88) still meets R3.6; if not, resolve memory from the root.
Rules for every workspace
| Topic | Rule |
|---|---|
| Runner | One Xum workspace per brief (W0 runs as W0a and W0b), started from fork main at its wave start. Every implementation runs implement-flow with the workstream issue as its input and the brief as the plan. |
| Branches | mike/<topic> for the workspace; stacked PR branches mike/<topic>-<n>-<slug>. Local name equals remote name. Never push to main. |
| PR size | 500 changed lines at most per PR, generated code excepted (reviewer-friendly-pr). Stack with gh stack; the extension is not installed on the Mac today (gh extension install github/gh-stack), else use explicit-base PRs. |
| Schema | Fork tables are chatd graph nodes: go run ./coderd/database/migrations/chatdmig/cmd/chatdmig new <name> -requires <node or upstream:name>. Never edit a node that ran. No edits to dump.sql, queries.sql.go, querier.go, dbmock or numbered migrations. |
| Queries | coderd/database/forkdb only (created by W0). Every method goes through the forkdb authz wrapper. A forkdb write that belongs with an upstream write runs in the same transaction, through the W0 accessor (database.Store exposes only InTx, coderd/database/db.go:22-31). |
| Authorization | Chat-owned rows authorize through the owning chat (dbauthz.go:6513-6522 pattern). Agent and plugin rows reuse the skill RBAC objects. No new RBAC resources, no new API key scopes. Tools run as the chatd subject, which can read and update every chat (dbauthz.go:807-817): a tool that touches a chat other than its own runs as the owner (asOwner, chattool/listtemplates.go:437-443). |
| Upstream files | One hook line per hot file (plan shared.2). Logic lives in new fork files. Hot files: turn_environment.go, chatd.go, subagent*.go, codersdk/chats.go, deployment.go, dbauthz.go, chat_routes.go, AgentChatInput, AgentChatPageView. |
| Open upstream PRs | If a workspace needs an open coder/coder PR, W0 or W7 merges its branch into the fork with a merge commit. Its migrations go through chatdmig route into the chatd schema. Sync conflicts are solved later (Mike, 2026-11-08). |
| Flags | Each feature is behind its fork-* experiment in codersdk/fork_experiments.go. With the flag off, tool lists, routes and UI match upstream. |
| API | Swagger annotations on new public endpoints. Audited types update enterprise/audit/table.go. |
| chatd docs | coderd/x/chatd/ARCHITECTURE.md gets TODO lines only. Mike writes the text. |
| Validation | Go suites run in Colima: a postgres:17 container, plus golang:<go.mod version>-bookworm --network container:<pg> with volumes coder-gen-gomod and coder-gen-gocache and postgresql-client-17 from PGDG. chatdmig tests use CHATDMIG_TEST_DATABASE_URL='postgres://[email protected]:5432/postgres?sslmode=disable'. Never create a postgres role on the live Postgres. Frontend: site/AGENTS.md commands plus frontend-deep-review for any site/ diff. |
| Review | implement-flow ends with codex-review-loop; Codex is installed (2026-11-08). If @codex review gets no reply within 30 minutes, tell the lead and run code-quality-review with Opus until Codex answers. Mike (2026-11-09): fix real defects in the PR's own change; drop scope creep and defensive bikeshedding with a one-line reply and a resolved thread, no follow-up issue. Upstream is only a sync source: never report or file anything upstream. |
| UAT | coder-agents-uat through Coder MCP on the local deployment (http://127.0.0.1:3000, templates devcontainer or docker, RUNBOOK "Running a branch in a dev container workspace"). The remote agent runs scripts/develop.sh for the branch inside its workspace (plan decision uat). Never coder-local use a branch build: that replaces Mike's daily server. |
| Ready | When a PR meets the merge bar, send the lead (task_send_message to 8ac7791132) READY #<pr> <head sha> with the CI, Codex, UAT and open-thread evidence, then wait. Never merge yourself. |
| Merge | The lead merges (Mike, 2026-11-08). Merge bar: green fork-ci on the exact head, a clean Codex verdict, or Codex findings that were all fixed or dropped under the scope rule (the lead confirms each drop), no unresolved threads, UAT PASS on the head or on a SHA whose later commits only answer review, and a lead review of the diff against the brief. Squash, except sync and upstream stack PRs, which take a merge commit. A merge to fork main deploys Mike's daily server through autodeploy within about 5 minutes plus a drain of up to 30 minutes, so the lead merges one PR at a time and waits until Fork ops reports the deploy healthy. Experiments stay off on that server until Mike enables them. |
| Follow-ups | A defect in merged code or on the daily server becomes an issue in ibetitsmike/coder with label followup. Fork ops triages it; an accepted one gets its own workspace running implement-flow. |
Activity
ibetitsmike commentedon Nov 9, 2026
Note
Xum posted this for Mike.
PR 1 (depth and limit) is open: #33. Next: spawn tools for non-root chats and direct-children narrowing.
ibetitsmike commentedon Nov 9, 2026
Note
Xum posted this for Mike.
PR 2 (spawn tools for non-root chats, direct-children targeting, full ancestor chain) is open: #37, stacked on #33.
ibetitsmike commentedon Nov 9, 2026
W2 status: READY sent for #33 (depth + limit) at 3454d7e. #37 (tools for non-root chats) green on dispatched fork-ci; READY follows once #33 merges and #37 targets main.
ibetitsmike commentedon Nov 9, 2026
W2 status: opened #42 (PR 3, interrupt cascade + archive of an active family), stacked on #37. #33 merged.
ibetitsmike commentedon Nov 9, 2026
W2 status: READY sent for #37 (tools for non-root chats) at 2933ad4.
ibetitsmike commentedon Nov 9, 2026
W2 status: opened #45 (PR 4, organization subagent limits; enforces the org
max_depth), stacked on #42 and #37. #37 is READY and waiting in the merge queue. #42 stays stacked until #37 merges. Next is PR 5, which enforces the capacity limits.ibetitsmike commentedon Nov 9, 2026
W2 status: opened #47 (PR 5, subagent concurrency limits per deployment, organization and family), stacked on #45. #37 merged
mainafter #38 and is re-running CI. Next is PR 6, which enforcesmax_live_per_family.ibetitsmike commentedon Nov 9, 2026
W2 status: #37 merged
mainafter #38 (head f5b5941, fork-ci green, patch unchanged apart from oneARCHITECTURE.mdTODO context line). READY re-sent.ibetitsmike commentedon Nov 9, 2026
W2 status: opened #49 (PR 6, live subagent limit per family, refused at spawn), stacked on #47. Next: the
waiting_for_capacitystate inlist_agents.ibetitsmike commentedon Nov 9, 2026
W2 status: #37 merged. Restacked onto
main: READY sent for #42 at 76cda6f; #45 is current at 22f0565 with a clean Codex review; #47 got a fix for a subagent pool deadlock (10e310a), and #49 now also checks the live limit onmessage_agentresume.ibetitsmike commentedon Nov 9, 2026
W2 status: #42 merged. #57 (PR 7, report subagents waiting for a concurrency slot) opened, stacked on #49.
ibetitsmike commentedon Nov 9, 2026
#45 (PR 4, org subagent limits) READY at 97544ab: Codex clean, fork-ci green.
ibetitsmike commentedon Nov 9, 2026
#47 (PR 5, subagent concurrency caps) READY at 390011f: Codex clean, fork-ci green, UAT round 2 passed.
ibetitsmike commentedon Nov 9, 2026
#47 (fair subagent capacity acquisition) READY at 0e846e7: CI green, Codex clean.
8 remaining items
ibetitsmike commentedon Nov 10, 2026
W2: #99 (nested descendants in chat list/GET) READY at 83e25a4. Merge after #104.
ibetitsmike commentedon Nov 10, 2026
W2: #104 (agent tree for depth>1 in the sidebar) READY at ab7392f. Merge before #99.
ibetitsmike commentedon Nov 10, 2026
W2: #109 opened (item 5b server half: family capacity endpoint for the sidebar badges).
ibetitsmike commentedon Nov 10, 2026
W2: #104 (agent tree for depth>1 in the sidebar) merged as 4b124f4. #99 next.
ibetitsmike commentedon Nov 10, 2026
W2: #99 (nested descendants in chat list/GET) merged as 26c1e02. #109 next.
ibetitsmike commentedon Nov 10, 2026
W2: #109 (family capacity endpoint) READY at d32bb19.
ibetitsmike commentedon Nov 10, 2026
W2: #109 (family capacity endpoint) merged as bfac64b.
ibetitsmike commentedon Nov 10, 2026
W2: opened #116 (sidebar family capacity markers, 5b-2 UI).
ibetitsmike commentedon Nov 10, 2026
W2: #116 (sidebar family capacity markers) READY at b26b7d5.
ibetitsmike commentedon Nov 10, 2026
W2: #116 (sidebar family capacity markers) merged as 4c0cf8c.
ibetitsmike commentedon Nov 10, 2026
W2: opened #127 (child chat top bar: waiting for a subagent slot).
ibetitsmike commentedon Nov 10, 2026
W2: #127 (child chat top bar: waiting for a subagent slot) READY at e6dbd96.
ibetitsmike commentedon Nov 10, 2026
W2: #127 (child chat top bar: waiting for a subagent slot) merged as 7161027.
ibetitsmike commentedon Nov 15, 2026
Closing as done, per Mike's decision on #219 (2026-11-15). Every PR this issue lists is merged; evidence: #4 (comment)