Repository navigation
feat: enforce the live subagent limit per family behind fork-nested-subagents - #49
Conversation
…ind fork-nested-subagents
…s, direct children only With fork-nested-subagents on, a general subagent below the maximum depth gets spawn_agent and the other subagent tools, keeps the orchestration prompt, and the subagent tools act only on the caller's direct children. With the experiment off, tools, prompts and target rules stay upstream's.
…nd spawn description Assert that wait, message and interrupt reject a grandchild, that list_agents works on a delegated chat and lists direct children only, that the spawn_agent description rewrite applies with the configured depth, and that appendForkTools leaves delegated chats untouched with fork experiments off.
…en and the depth flag
The Coder-Ancestor-Chat-Ids header carried only the immediate parent, so a grandchild's file edits and commands were never attributed to the family root's path store and the root's git watch and diff omitted that work. Resolve the chain with a new chatd helper: nil for a root, the parent alone when fork-nested-subagents is off (upstream behavior, no extra queries), and the full chain nearest ancestor first up to the root when it is on. A failed lookup warns and keeps the ancestors found so far.
…for subagent depth
…nto mike/nested-subagents-2-tools # Conflicts: # coderd/x/chatd/ARCHITECTURE.md # coderd/x/chatd/fork_tools.go
…-2-tools # Conflicts: # coderd/x/chatd/fork_subagents.go # coderd/x/chatd/fork_subagents_internal_test.go
…nto mike/nested-subagents-3-cascade # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/forkdbmock/forkdbmock.go # coderd/database/forkdb/querier.go
…description cannot read organization limits
…d spawn pre-check
…' into mike/nested-subagents-6-live-cap
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…ir family A coordinator that holds its family's last slot while it waits in wait_agent can only make progress through its own child, which excludes it from the family count. Older queued siblings, which cannot fit, kept that child out of the bounded candidates.
…' into mike/nested-subagents-6-live-cap
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…' into mike/nested-subagents-6-live-cap # Conflicts: # coderd/x/chatd/fork_subagents.go
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15acf45ae9
ℹ️ 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".
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merge evidence for head
|
Part of #8 (W2 nested subagents, PR 6 of the stack). Stacked on #47: review only the commits after #47.
With
fork-nested-subagentson, spawning a subagent fails when its family (one root chat and its descendants) already has the maximum number of live subagents. With the experiment off, nothing changes.running,interrupting,requires_actionorpaused. A subagent that finished (waitingorerror) does not count, so the family can spawn again once a child finishes.--chat-max-live-subagents-per-family(CODER_CHAT_MAX_LIVE_SUBAGENTS_PER_FAMILY), default 0 (no limit), negative values rejected. The organization'smax_live_per_family, stored since feat: store organization subagent limits and enforce max_depth behind fork-nested-subagents #45, now applies and lowers the deployment value, the same rule as the concurrency limits in feat: enforce subagent concurrency limits behind fork-nested-subagents #47.message_agentto a finished child (waitingorerror) would make it live again.sendSubagentMessageruns the same count beforeSendMessage, so a capped resume fails before any prompt hook fires. It also marks its send context, andSendMessagecounts again inside the transaction that resumes the child, under the same per-family advisory lock, so a resume and a concurrent spawn cannot both pass the count. Owner messages through the chat API are not limited. This adds one hook line to upstream'sSendMessageand a few lines tosendSubagentMessage.ARCHITECTURE.mdgets only a TODO for the author.Validation
go test ./coderd/x/chatd/, plus./coderd/database/forkdb/...,./coderd/database/dbauthz/,./codersdk/and the CLI help and YAML goldens (OSS and enterprise).forkdb/generate.shand thetypesGenerated.tsregeneration leave no diff.TestCountLiveSubagentsInFamily(counts only unarchived, unfinished subagents of the family),TestNestedSubagentLiveLimit(a second spawn fails at the limit, the limit covers grandchildren, the pre-check fails too, and a finished child frees the slot, andmessage_agentcannot resume a finished child over the limit),TestNestedSubagentLiveLimitSerializesResume(a resume waits for a spawn that holds the family lock, then counts its child), plus the flag case inTestForkChatSubagentCapacityOptions.main, so CI for this stacked PR runs throughworkflow_dispatchon the branch until it targetsmain.