Skip to content

[codex] Add model multi-agent system overlay#25155

Closed
aibrahim-oai wants to merge 3 commits into
codex/persist-multi-agent-runtimefrom
codex/model-info-multi-agent-overlay
Closed

[codex] Add model multi-agent system overlay#25155
aibrahim-oai wants to merge 3 commits into
codex/persist-multi-agent-runtimefrom
codex/model-info-multi-agent-overlay

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

@aibrahim-oai aibrahim-oai commented May 29, 2026

Why

New root threads need a constrained catalog selector for the multi-agent system without expanding Config. PR #25168 owns the thread-scoped session lock; this PR adds one catalog input when that lock is initially chosen.

What changed

  • Add optional ModelInfo.multi_agent_version with known v1 and v2 values.
  • Treat omitted and unknown future wire values as None, so they follow the existing flag fallback.
  • Resolve once when the session starts in this order: persisted or inherited value, known ModelInfo selector, then existing flags.
  • Store and carry the resolved value through the existing PR [codex] Pin multi-agent system per thread #25168 session lock. Do not re-resolve after thread start or model switches.
  • Keep bundled catalog entries omitted. Do not add Config, ModelPreset, or app-server DTO fields.
  • Make the catalog-overlay E2E fixture start the root thread directly with the selected catalog model and assert the first outbound tool family.

Verification

Added protocol coverage for omitted, known, and unknown values. Added request-boundary integration coverage for explicit catalog overrides and omitted or unknown fallback, plus focused coverage that inherited parent state wins over conflicting catalog metadata. Ran just fmt. Validation is running in online CI.

Stack

  1. Metadata storage: [codex] Persist multi-agent version metadata #25153
  2. Runtime pinning and session lock: [codex] Pin multi-agent system per thread #25168
  3. This PR: [codex] Add model multi-agent system overlay #25155

Supersedes #25032.

@aibrahim-oai aibrahim-oai requested a review from a team as a code owner May 29, 2026 21:08
@aibrahim-oai aibrahim-oai force-pushed the codex/model-info-multi-agent-overlay branch from d0bfbd8 to 8f6c1ed Compare May 29, 2026 21:15
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 8f6c1eda81

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

}
})
inherited_multi_agent_version
.or_else(|| model_info.and_then(|model_info| model_info.multi_agent_version))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor model-selected V2 concurrency limits

When a backend model sets multi_agent_version = V2 while the local Feature::MultiAgentV2 flag is disabled, this path now enables the V2 tool surface, but Config::load still derives agent_max_threads only from the feature flag (config/mod.rs uses the legacy agents.max_threads/default in that case). Since spawn_agent enforces config.agent_max_threads via reserve_spawn_slot, these model-selected V2 sessions can advertise multi_agent_v2.max_concurrent_threads_per_session but still reject spawns at the legacy cap, e.g. a model-marked V2 session with the feature disabled and a configured cap of 17 is limited to the default 6 children.

Useful? React with 👍 / 👎.

Comment on lines 922 to 926
&config,
&session_source,
history.get_multi_agent_version(),
/*model_info*/ None,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use model selectors for interrupted forks

For interrupted forks whose stored history does not already contain multi_agent_version (for example legacy rollouts), this pre-spawn resolution cannot see a backend model marked as V2 when the local MultiAgentV2 flag is off, so fork_history_from_snapshot appends the legacy contextual-user interruption marker. The new session is then initialized through Codex::spawn, where the same model metadata can resolve the thread to V2, leaving a V2 thread with the wrong interrupted-turn marker in its model context; the live V2 interrupt path uses the developer marker instead.

Useful? React with 👍 / 👎.

Comment thread codex-rs/core/src/agent/control.rs Outdated
Comment on lines +623 to +626
&config,
&session_source,
stored_thread.multi_agent_version,
/*model_info*/ None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid legacy watchers for model-selected V2 resumes

When resuming a stored child thread that predates persisted multi_agent_version, this resolution ignores the child model metadata, so a backend-marked V2 child with the local V2 feature disabled is treated as non-V2 here and gets maybe_start_completion_watcher attached. The resumed session itself can still resolve to V2 during Codex::spawn, so final turns are reported both by the V2 terminal-turn forwarding path and by this legacy watcher, causing duplicate completion messages to the parent for those resumed subagents.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai force-pushed the codex/model-info-multi-agent-overlay branch from 8f6c1ed to 72b1232 Compare May 29, 2026 21:38
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 72b1232ae9

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

}
})
inherited_multi_agent_version
.or_else(|| model_info.and_then(|model_info| model_info.multi_agent_version))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep V1-selected sessions on V1 thread limits

When a backend model selects multi_agent_version = V1 while Feature::MultiAgentV2 is enabled, this resolves the session to the V1 tool surface but leaves Config::load having derived config.agent_max_threads from features.multi_agent_v2.max_concurrent_threads_per_session and rejecting agents.max_threads; spawn_agent then enforces that mismatched V2-derived cap via reserve_spawn_slot. In that configuration a model intentionally pinned to V1 cannot use the legacy V1 concurrency setting and may allow/reject spawns according to the wrong limit, even though the tools and prompts are V1.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai force-pushed the codex/persist-multi-agent-system branch from d617fd1 to 88f1739 Compare May 29, 2026 22:33
@aibrahim-oai aibrahim-oai force-pushed the codex/model-info-multi-agent-overlay branch from e7021b0 to f32ec83 Compare May 29, 2026 22:39
@aibrahim-oai aibrahim-oai changed the base branch from codex/persist-multi-agent-system to codex/persist-multi-agent-runtime May 29, 2026 22:39
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