[codex] Add Ultra reasoning effort (#29899)

## Why

Ultra should be one user-facing reasoning selection for work that
benefits from both maximum reasoning and proactive multi-agent
delegation. Without it, clients must coordinate maximum reasoning with
the experimental `multiAgentMode` setting, even though the inference
backend still expects its existing `max` effort value.

This change makes reasoning effort the source of truth: clients select
`ultra`, core derives proactive multi-agent behavior when the turn is
eligible for multi-agent V2, and inference requests continue to use the
backend-compatible `max` value.

## What changed

- Add `ultra` as a first-class reasoning effort and preserve
model-catalog ordering when exposing it to clients.
- Convert `ultra` to `max` at the inference request boundary, including
Responses HTTP/WebSocket requests, startup prewarm, compaction, and
memory summarization.
- Derive effective multi-agent mode per turn from effective reasoning
effort:
  - eligible multi-agent V2 + `ultra` → `proactive`
  - eligible multi-agent V2 + any other effort → `explicitRequestOnly`
- V1 or otherwise ineligible sessions → no multi-agent mode instruction
- Keep the derived effective mode in turn context history so successive
turns can emit a developer-message update only when the effective mode
changes.
- Remove selected multi-agent mode from core session configuration, turn
construction, thread settings, resume/fork restoration, and subagent
spawn plumbing. Subagents inherit reasoning effort and derive their own
effective mode.
- Retain the experimental app-server `multiAgentMode` fields for wire
compatibility while marking them deprecated. Request values are accepted
but ignored; compatibility response fields report `explicitRequestOnly`.
- Display Ultra in the TUI using the order supplied by `model/list`.

## Validation

- `just test -p codex-core ultra_reasoning_uses_max_for_requests`
- `just test -p codex-tui model_reasoning_selection_popup`
This commit is contained in:
Shijie Rao
2026-06-24 20:13:52 -07:00
committed by GitHub
Unverified
parent fa036d39aa
commit df1199fddb
41 changed files with 172 additions and 651 deletions
@@ -94,9 +94,7 @@ pub struct ThreadStartParams {
pub developer_instructions: Option<String>,
#[ts(optional = nullable)]
pub personality: Option<Personality>,
/// Set the initial multi-agent mode for this thread. `none` leaves the
/// multi-agent tools available without injecting mode instructions.
/// Omitted defaults to `explicitRequestOnly`.
/// @deprecated Ignored. Use Ultra reasoning effort for proactive multi-agent behavior.
#[experimental("thread/start.multiAgentMode")]
#[ts(optional = nullable)]
pub multi_agent_mode: Option<MultiAgentMode>,
@@ -186,7 +184,7 @@ pub struct ThreadStartResponse {
#[serde(default)]
pub active_permission_profile: Option<ActivePermissionProfile>,
pub reasoning_effort: Option<ReasoningEffort>,
/// Current multi-agent mode for this thread.
/// @deprecated Always `explicitRequestOnly`. Use `reasoningEffort` for Ultra behavior.
#[experimental("thread/start.multiAgentMode")]
#[serde(default)]
pub multi_agent_mode: MultiAgentMode,
@@ -250,7 +248,7 @@ pub struct ThreadSettingsUpdateParams {
#[experimental("thread/settings/update.collaborationMode")]
#[ts(optional = nullable)]
pub collaboration_mode: Option<CollaborationMode>,
/// Select the multi-agent mode for subsequent turns.
/// @deprecated Ignored. Use `effort: "ultra"` for proactive multi-agent behavior.
#[experimental("thread/settings/update.multiAgentMode")]
#[ts(optional = nullable)]
pub multi_agent_mode: Option<MultiAgentMode>,
@@ -279,7 +277,7 @@ pub struct ThreadSettings {
pub effort: Option<ReasoningEffort>,
pub summary: Option<ReasoningSummary>,
pub collaboration_mode: CollaborationMode,
/// Current multi-agent mode for this thread.
/// @deprecated Always `explicitRequestOnly`. Use `effort` for Ultra behavior.
#[experimental("thread/settings.multiAgentMode")]
#[serde(default)]
pub multi_agent_mode: MultiAgentMode,
@@ -419,7 +417,7 @@ pub struct ThreadResumeResponse {
#[serde(default)]
pub active_permission_profile: Option<ActivePermissionProfile>,
pub reasoning_effort: Option<ReasoningEffort>,
/// Current multi-agent mode for this thread.
/// @deprecated Always `explicitRequestOnly`. Use `reasoningEffort` for Ultra behavior.
#[experimental("thread/resume.multiAgentMode")]
#[serde(default)]
pub multi_agent_mode: MultiAgentMode,
@@ -578,7 +576,7 @@ pub struct ThreadForkResponse {
#[serde(default)]
pub active_permission_profile: Option<ActivePermissionProfile>,
pub reasoning_effort: Option<ReasoningEffort>,
/// Current multi-agent mode for this thread.
/// @deprecated Always `explicitRequestOnly`. Use `reasoningEffort` for Ultra behavior.
#[experimental("thread/fork.multiAgentMode")]
#[serde(default)]
pub multi_agent_mode: MultiAgentMode,
@@ -151,9 +151,7 @@ pub struct TurnStartParams {
#[ts(optional = nullable)]
pub collaboration_mode: Option<CollaborationMode>,
/// Controls multi-agent v2 delegation instructions. `none` leaves the
/// multi-agent tools available without injecting mode instructions. Omitted
/// keeps the loaded session's current mode.
/// @deprecated Ignored. Use `effort: "ultra"` for proactive multi-agent behavior.
#[experimental("turn/start.multiAgentMode")]
#[ts(optional = nullable)]
pub multi_agent_mode: Option<MultiAgentMode>,