Repository navigation
Enforce bounded MultiAgent V2 nesting - #1
Merged
Merged
Conversation
MultiAgent V2 collapsed an omitted `fork_turns` to a full-history fork before considering routing intent, so any spawn that requested an `agent_type`, `model`, or `reasoning_effort` while omitting `fork_turns` was rejected outright by `reject_full_fork_spawn_overrides`. Make `SpawnAgentArgs::fork_mode` intent-aware: an omitted or blank `fork_turns` combined with an explicit route now resolves to a fresh child so the override is honored, while a spawn with no routing override keeps the inherited full-history default. Explicit `fork_turns` semantics are unchanged (`none`/`all`/positive integer), and explicit `fork_turns = "all"` still rejects overrides. Add unit coverage over the fork-resolution matrix and repurpose the test that encoded the old sharp edge into a handler-level test of the new behavior. Start PATCHES.md to track fork customizations. Upstream: openai#32031 Co-Authored-By: Claude <[email protected]>
Add a ResolvedSubagentRoute record capturing how a spawned child's route resolved — agent_type, model, reasoning effort, service tier, and fork mode — with each value tagged by provenance (explicit argument, custom agent file, parent inheritance, model-catalog default, or client default). Effective values are read from the child's runtime config snapshot rather than any self-report, and an explicit request that does not match the effective value is recorded as a warning. The route is returned only on the un-hidden WithNickname result, so the reserved collaboration.spawn_agent (HiddenMetadata) schema stays byte-for-byte compatible. Permission profile and per-child usage are deferred to the surfacing patch. The route is boxed in the result enum to satisfy large_enum_variant. Co-Authored-By: Claude <[email protected]>
Add features.multi_agent_v2.require_explicit_agent_type (default false, opt-in). When enabled, a spawn_agent call that omits agent_type is rejected before a child thread is created, so strict swarms never fall back to a generic inherited child instead of an explicitly routed role. Default behavior is unchanged. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]>
Add features.multi_agent_v2.reject_route_substitution (default false, opt-in). When enabled, a spawn_agent call whose explicit model or reasoning_effort conflicts with the value pinned by the selected role is rejected before a child thread is created, instead of silently substituting the role's value. Detection reads the role file's declared model/model_reasoning_effort, so it never false-rejects a role that does not pin the field. Also backfills the require_explicit_agent_type field in a features-crate test initializer and regenerates config.schema.json. Co-Authored-By: Claude <[email protected]>
Add features.multi_agent_v2.max_total_spawns_per_root (default none = unbounded). A shared, never-decremented counter on AgentControl tracks how many sub-agents a root has spawned via the multi-agent spawn tool; the V2 spawn handler rejects a spawn before creating a child once the budget is reached, so a swarm cannot fan out past a configured limit. The counter is an Arc<AtomicUsize> shared across a root's sibling control handles; it counts model-driven spawn_agent fan-out (not forks or resumes) and is checked in the handler rather than threaded through the concurrency-critical reservation flow. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]>
Rebased the subagent-routing stack from 9e552e9 onto upstream c888e8e (composer completion work, openai#32628). The synced commit is TUI-only with no file overlap, so the rebase was conflict-free and the stack re-validated green (fmt/clippy clean; codex-core + codex-features tests pass). Updates the recorded fork base in PATCHES.md. Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Codex <[email protected]>
jessatech
marked this pull request as ready for review
July 13, 2026 18:30
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d47fae000
ℹ️ 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".
Co-Authored-By: Codex <[email protected]>
jessatech
added a commit
that referenced
this pull request
Jul 13, 2026
* Fix intent-incompatible fork default for routed subagent spawns MultiAgent V2 collapsed an omitted `fork_turns` to a full-history fork before considering routing intent, so any spawn that requested an `agent_type`, `model`, or `reasoning_effort` while omitting `fork_turns` was rejected outright by `reject_full_fork_spawn_overrides`. Make `SpawnAgentArgs::fork_mode` intent-aware: an omitted or blank `fork_turns` combined with an explicit route now resolves to a fresh child so the override is honored, while a spawn with no routing override keeps the inherited full-history default. Explicit `fork_turns` semantics are unchanged (`none`/`all`/positive integer), and explicit `fork_turns = "all"` still rejects overrides. Add unit coverage over the fork-resolution matrix and repurpose the test that encoded the old sharp edge into a handler-level test of the new behavior. Start PATCHES.md to track fork customizations. Upstream: openai#32031 Co-Authored-By: Claude <[email protected]> * Report resolved subagent route with provenance on spawn Add a ResolvedSubagentRoute record capturing how a spawned child's route resolved — agent_type, model, reasoning effort, service tier, and fork mode — with each value tagged by provenance (explicit argument, custom agent file, parent inheritance, model-catalog default, or client default). Effective values are read from the child's runtime config snapshot rather than any self-report, and an explicit request that does not match the effective value is recorded as a warning. The route is returned only on the un-hidden WithNickname result, so the reserved collaboration.spawn_agent (HiddenMetadata) schema stays byte-for-byte compatible. Permission profile and per-child usage are deferred to the surfacing patch. The route is boxed in the result enum to satisfy large_enum_variant. Co-Authored-By: Claude <[email protected]> * Add strict-routing option to require an explicit agent_type Add features.multi_agent_v2.require_explicit_agent_type (default false, opt-in). When enabled, a spawn_agent call that omits agent_type is rejected before a child thread is created, so strict swarms never fall back to a generic inherited child instead of an explicitly routed role. Default behavior is unchanged. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Reject route substitution when a role pins a conflicting model or effort Add features.multi_agent_v2.reject_route_substitution (default false, opt-in). When enabled, a spawn_agent call whose explicit model or reasoning_effort conflicts with the value pinned by the selected role is rejected before a child thread is created, instead of silently substituting the role's value. Detection reads the role file's declared model/model_reasoning_effort, so it never false-rejects a role that does not pin the field. Also backfills the require_explicit_agent_type field in a features-crate test initializer and regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Add a per-root total-spawn budget cap Add features.multi_agent_v2.max_total_spawns_per_root (default none = unbounded). A shared, never-decremented counter on AgentControl tracks how many sub-agents a root has spawned via the multi-agent spawn tool; the V2 spawn handler rejects a spawn before creating a child once the budget is reached, so a swarm cannot fan out past a configured limit. The counter is an Arc<AtomicUsize> shared across a root's sibling control handles; it counts model-driven spawn_agent fan-out (not forks or resumes) and is checked in the handler rather than threaded through the concurrency-critical reservation flow. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Record upstream sync: rebase stack onto c888e8e Rebased the subagent-routing stack from 9e552e9 onto upstream c888e8e (composer completion work, openai#32628). The synced commit is TUI-only with no file overlap, so the rebase was conflict-free and the stack re-validated green (fmt/clippy clean; codex-core + codex-features tests pass). Updates the recorded fork base in PATCHES.md. Co-Authored-By: Claude <[email protected]> * Enforce bounded MultiAgent V2 nesting Co-Authored-By: Codex <[email protected]> * Keep V2 depth rooted in parent session Co-Authored-By: Codex <[email protected]> --------- Co-authored-by: Claude <[email protected]>
jessatech
added a commit
that referenced
this pull request
Jul 15, 2026
* Fix intent-incompatible fork default for routed subagent spawns MultiAgent V2 collapsed an omitted `fork_turns` to a full-history fork before considering routing intent, so any spawn that requested an `agent_type`, `model`, or `reasoning_effort` while omitting `fork_turns` was rejected outright by `reject_full_fork_spawn_overrides`. Make `SpawnAgentArgs::fork_mode` intent-aware: an omitted or blank `fork_turns` combined with an explicit route now resolves to a fresh child so the override is honored, while a spawn with no routing override keeps the inherited full-history default. Explicit `fork_turns` semantics are unchanged (`none`/`all`/positive integer), and explicit `fork_turns = "all"` still rejects overrides. Add unit coverage over the fork-resolution matrix and repurpose the test that encoded the old sharp edge into a handler-level test of the new behavior. Start PATCHES.md to track fork customizations. Upstream: openai#32031 Co-Authored-By: Claude <[email protected]> * Report resolved subagent route with provenance on spawn Add a ResolvedSubagentRoute record capturing how a spawned child's route resolved — agent_type, model, reasoning effort, service tier, and fork mode — with each value tagged by provenance (explicit argument, custom agent file, parent inheritance, model-catalog default, or client default). Effective values are read from the child's runtime config snapshot rather than any self-report, and an explicit request that does not match the effective value is recorded as a warning. The route is returned only on the un-hidden WithNickname result, so the reserved collaboration.spawn_agent (HiddenMetadata) schema stays byte-for-byte compatible. Permission profile and per-child usage are deferred to the surfacing patch. The route is boxed in the result enum to satisfy large_enum_variant. Co-Authored-By: Claude <[email protected]> * Add strict-routing option to require an explicit agent_type Add features.multi_agent_v2.require_explicit_agent_type (default false, opt-in). When enabled, a spawn_agent call that omits agent_type is rejected before a child thread is created, so strict swarms never fall back to a generic inherited child instead of an explicitly routed role. Default behavior is unchanged. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Reject route substitution when a role pins a conflicting model or effort Add features.multi_agent_v2.reject_route_substitution (default false, opt-in). When enabled, a spawn_agent call whose explicit model or reasoning_effort conflicts with the value pinned by the selected role is rejected before a child thread is created, instead of silently substituting the role's value. Detection reads the role file's declared model/model_reasoning_effort, so it never false-rejects a role that does not pin the field. Also backfills the require_explicit_agent_type field in a features-crate test initializer and regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Add a per-root total-spawn budget cap Add features.multi_agent_v2.max_total_spawns_per_root (default none = unbounded). A shared, never-decremented counter on AgentControl tracks how many sub-agents a root has spawned via the multi-agent spawn tool; the V2 spawn handler rejects a spawn before creating a child once the budget is reached, so a swarm cannot fan out past a configured limit. The counter is an Arc<AtomicUsize> shared across a root's sibling control handles; it counts model-driven spawn_agent fan-out (not forks or resumes) and is checked in the handler rather than threaded through the concurrency-critical reservation flow. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Record upstream sync: rebase stack onto c888e8e Rebased the subagent-routing stack from 9e552e9 onto upstream c888e8e (composer completion work, openai#32628). The synced commit is TUI-only with no file overlap, so the rebase was conflict-free and the stack re-validated green (fmt/clippy clean; codex-core + codex-features tests pass). Updates the recorded fork base in PATCHES.md. Co-Authored-By: Claude <[email protected]> * Enforce bounded MultiAgent V2 nesting Co-Authored-By: Codex <[email protected]> * Keep V2 depth rooted in parent session Co-Authored-By: Codex <[email protected]> --------- Co-authored-by: Claude <[email protected]>
jessatech
added a commit
that referenced
this pull request
Aug 6, 2026
* Fix intent-incompatible fork default for routed subagent spawns MultiAgent V2 collapsed an omitted `fork_turns` to a full-history fork before considering routing intent, so any spawn that requested an `agent_type`, `model`, or `reasoning_effort` while omitting `fork_turns` was rejected outright by `reject_full_fork_spawn_overrides`. Make `SpawnAgentArgs::fork_mode` intent-aware: an omitted or blank `fork_turns` combined with an explicit route now resolves to a fresh child so the override is honored, while a spawn with no routing override keeps the inherited full-history default. Explicit `fork_turns` semantics are unchanged (`none`/`all`/positive integer), and explicit `fork_turns = "all"` still rejects overrides. Add unit coverage over the fork-resolution matrix and repurpose the test that encoded the old sharp edge into a handler-level test of the new behavior. Start PATCHES.md to track fork customizations. Upstream: openai#32031 Co-Authored-By: Claude <[email protected]> * Report resolved subagent route with provenance on spawn Add a ResolvedSubagentRoute record capturing how a spawned child's route resolved — agent_type, model, reasoning effort, service tier, and fork mode — with each value tagged by provenance (explicit argument, custom agent file, parent inheritance, model-catalog default, or client default). Effective values are read from the child's runtime config snapshot rather than any self-report, and an explicit request that does not match the effective value is recorded as a warning. The route is returned only on the un-hidden WithNickname result, so the reserved collaboration.spawn_agent (HiddenMetadata) schema stays byte-for-byte compatible. Permission profile and per-child usage are deferred to the surfacing patch. The route is boxed in the result enum to satisfy large_enum_variant. Co-Authored-By: Claude <[email protected]> * Add strict-routing option to require an explicit agent_type Add features.multi_agent_v2.require_explicit_agent_type (default false, opt-in). When enabled, a spawn_agent call that omits agent_type is rejected before a child thread is created, so strict swarms never fall back to a generic inherited child instead of an explicitly routed role. Default behavior is unchanged. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Reject route substitution when a role pins a conflicting model or effort Add features.multi_agent_v2.reject_route_substitution (default false, opt-in). When enabled, a spawn_agent call whose explicit model or reasoning_effort conflicts with the value pinned by the selected role is rejected before a child thread is created, instead of silently substituting the role's value. Detection reads the role file's declared model/model_reasoning_effort, so it never false-rejects a role that does not pin the field. Also backfills the require_explicit_agent_type field in a features-crate test initializer and regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Add a per-root total-spawn budget cap Add features.multi_agent_v2.max_total_spawns_per_root (default none = unbounded). A shared, never-decremented counter on AgentControl tracks how many sub-agents a root has spawned via the multi-agent spawn tool; the V2 spawn handler rejects a spawn before creating a child once the budget is reached, so a swarm cannot fan out past a configured limit. The counter is an Arc<AtomicUsize> shared across a root's sibling control handles; it counts model-driven spawn_agent fan-out (not forks or resumes) and is checked in the handler rather than threaded through the concurrency-critical reservation flow. Regenerates config.schema.json. Co-Authored-By: Claude <[email protected]> * Record upstream sync: rebase stack onto c888e8e Rebased the subagent-routing stack from 9e552e9 onto upstream c888e8e (composer completion work, openai#32628). The synced commit is TUI-only with no file overlap, so the rebase was conflict-free and the stack re-validated green (fmt/clippy clean; codex-core + codex-features tests pass). Updates the recorded fork base in PATCHES.md. Co-Authored-By: Claude <[email protected]> * Enforce bounded MultiAgent V2 nesting Co-Authored-By: Codex <[email protected]> * Keep V2 depth rooted in parent session Co-Authored-By: Codex <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
features.multi_agent_v2.max_depthwith default 2 and supported range 1–4Root cause
The previous remediation conflated lifetime usage with concurrency and left V2 depth advisory. Separately, applying an explicit model before rebuilding a non-empty role layer could silently restore the parent model when the role did not pin one.
Behavior
The default topology is
root → subagent → child. Maximum-depth agents keep management tools but cannot spawn. Sequential completed children do not consume a permanent lifetime budget. Fresh explicit routes may choose a different child model—for example, a Sol orchestrator can route a Terra reader—unless the selected role explicitly pins a conflicting route.The removed
max_total_spawns_per_rootkey is intentionally unsupported; developer configs carrying it must delete it.Validation
just write-config-schemajust test -p codex-features(55 passed)just test -p codex-config(200 passed)codex-coreV2 tests (75 relevant tests passed across focused runs)just test -p codex-core multi_agents_spec(10 passed)just fix -p codex-core -p codex-config -p codex-featuresjust fmtgit diff --checkFull workspace tests were not run.