Skip to content

Expose thread-level multi-agent mode#28792

Open
shijie-oai wants to merge 1 commit into
shijie/ma-v2-modefrom
shijie/ma-v2-mode-lifecycle
Open

Expose thread-level multi-agent mode#28792
shijie-oai wants to merge 1 commit into
shijie/ma-v2-modefrom
shijie/ma-v2-mode-lifecycle

Conversation

@shijie-oai

@shijie-oai shijie-oai commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Why

Once multi-agent mode can be selected per turn, clients also need to choose the initial selection when creating a thread and observe that selection through lifecycle and settings APIs.

The selected value is intentionally distinct from the effective model-visible value: no client selection is represented as null, even though an eligible multi-agent v2 turn derives explicitRequestOnly as its effective default.

What changed

  • Add the optional experimental thread/start.multiAgentMode parameter and pass it through thread creation.
  • Preserve an omitted initial value as an unset selection rather than eagerly storing explicitRequestOnly.
  • Apply an explicit thread/start selection to the first turn through the session configuration established at thread creation.
  • Restore the latest persisted effective mode as the selected baseline on cold resume when rollout history contains one.
  • Inherit the optional selected mode from a loaded parent when creating related runtime threads.
  • Return the current selected multiAgentMode from thread/start, thread/resume, thread/fork, and thread settings, using null when no mode is selected.
  • Keep lifecycle reporting independent from model capability and feature eligibility; core turn construction remains responsible for calculating and persisting the effective mode.

Not covered

  • Clearing an existing loaded-session selection back to unset through turn/start; omitted or null currently retains the session's selection.
  • A TUI control, slash command, or config.toml preference.

Verification

  • CARGO_INCREMENTAL=0 just test -p codex-app-server-protocol
  • CARGO_INCREMENTAL=0 just test -p codex-app-server multi_agent_mode

The focused app-server coverage verifies explicit thread/start initialization, first-turn prompting, nullable reporting for an omitted selection, and retention of selections that are not currently runtime-eligible.

Stack

Stacked on #28685. This PR contains only the thread initialization and lifecycle/settings API layer.

@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch from f0b05d4 to 5a272c7 Compare June 17, 2026 22:00
@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch from 5a272c7 to a113393 Compare June 17, 2026 22:05
@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch from a113393 to 180fa9b Compare June 17, 2026 22:14
@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch from 180fa9b to 07d718f Compare June 17, 2026 22:18
@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch 2 times, most recently from f4d3cce to c992e15 Compare June 17, 2026 23:25
@shijie-oai shijie-oai force-pushed the shijie/ma-v2-mode-lifecycle branch from c992e15 to 6a0aad7 Compare June 18, 2026 00:19
@shijie-oai shijie-oai marked this pull request as ready for review June 18, 2026 00:35
@shijie-oai shijie-oai requested a review from a team as a code owner June 18, 2026 00:35

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

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a0aad7247

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

Comment on lines +581 to +582
let multi_agent_mode =
initial_multi_agent_mode.or_else(|| conversation_history.get_multi_agent_mode());

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 Preserve selected mode across cold resume

When thread/start.multiAgentMode is supplied, this only seeds the live session; cold resume reconstructs the setting from conversation_history.get_multi_agent_mode(), which reads the persisted effective turn mode rather than the selected thread mode. In inspected app-server resume/fork paths, this means a thread started with proactive can later resume as null if it had no turns or as explicitRequestOnly/null when the selected mode was not applicable or was downgraded for the turn, so clients cannot recover the selected thread-level mode the new lifecycle API promises. Persist and restore the selected mode separately from the effective model-visible mode.

AGENTS.md reference: AGENTS.md:L103-L110

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant