mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
[codex] Add Ultra reasoning effort (#29899)
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. - 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`. - `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:
committed by
shijie-openai
parent
27f22b54ae
commit
aedb8f345a
@@ -22,10 +22,7 @@ use codex_app_server_protocol::TurnStartParams;
|
||||
use codex_app_server_protocol::TurnStartResponse;
|
||||
use codex_app_server_protocol::UserInput as V2UserInput;
|
||||
use codex_core::test_support::all_model_presets;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::config_types::MultiAgentMode;
|
||||
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
|
||||
use codex_protocol::protocol::MULTI_AGENT_MODE_OPEN_TAG;
|
||||
use core_test_support::responses;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
@@ -97,109 +94,6 @@ async fn thread_settings_update_emits_notification_and_updates_future_turns() ->
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_settings_update_multi_agent_mode_applies_to_future_turns() -> Result<()> {
|
||||
let server = responses::start_mock_server().await;
|
||||
let response_mock = responses::mount_sse_sequence(
|
||||
&server,
|
||||
(1..=2)
|
||||
.map(|index| {
|
||||
responses::sse(vec![
|
||||
responses::ev_response_created(&format!("resp-{index}")),
|
||||
responses::ev_assistant_message(&format!("msg-{index}"), "done"),
|
||||
responses::ev_completed(&format!("resp-{index}")),
|
||||
])
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
.await;
|
||||
let codex_home = TempDir::new()?;
|
||||
write_mock_responses_config_toml(
|
||||
codex_home.path(),
|
||||
&server.uri(),
|
||||
&BTreeMap::from([(Feature::MultiAgentV2, true)]),
|
||||
/*auto_compact_limit*/ 200_000,
|
||||
/*requires_openai_auth*/ None,
|
||||
"mock_provider",
|
||||
"compact",
|
||||
)?;
|
||||
|
||||
let mut mcp = TestAppServer::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
||||
let thread = start_thread(&mut mcp).await?.thread;
|
||||
|
||||
start_text_turn(&mut mcp, thread.id.clone()).await?;
|
||||
timeout(
|
||||
DEFAULT_TIMEOUT,
|
||||
mcp.read_stream_until_notification_message("turn/completed"),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(response_mock.requests().len(), 1);
|
||||
|
||||
send_thread_settings_update(
|
||||
&mut mcp,
|
||||
ThreadSettingsUpdateParams {
|
||||
thread_id: thread.id.clone(),
|
||||
multi_agent_mode: Some(MultiAgentMode::Proactive),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
response_mock.requests().len(),
|
||||
1,
|
||||
"settings-only update should not start a model request"
|
||||
);
|
||||
|
||||
let updated = read_thread_settings_updated(&mut mcp).await?;
|
||||
assert_eq!(updated.thread_id, thread.id);
|
||||
assert_eq!(
|
||||
updated.thread_settings.multi_agent_mode,
|
||||
MultiAgentMode::Proactive
|
||||
);
|
||||
|
||||
start_text_turn(&mut mcp, thread.id).await?;
|
||||
timeout(
|
||||
DEFAULT_TIMEOUT,
|
||||
mcp.read_stream_until_notification_message("turn/completed"),
|
||||
)
|
||||
.await??;
|
||||
|
||||
let requests = response_mock.requests();
|
||||
let first_developer_texts = requests[0].message_input_texts("developer");
|
||||
let second_developer_texts = requests[1].message_input_texts("developer");
|
||||
assert_eq!(
|
||||
first_developer_texts
|
||||
.iter()
|
||||
.filter(|text| text.contains(MULTI_AGENT_MODE_OPEN_TAG))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
second_developer_texts
|
||||
.iter()
|
||||
.filter(|text| text.contains(MULTI_AGENT_MODE_OPEN_TAG))
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
assert_eq!(
|
||||
second_developer_texts
|
||||
.iter()
|
||||
.filter(|text| text.contains("Proactive multi-agent delegation is active."))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
second_developer_texts
|
||||
.iter()
|
||||
.filter(|text| text
|
||||
.contains("Do not spawn sub-agents unless the user explicitly asks for sub-agents"))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_settings_update_cwd_retargets_default_environment() -> Result<()> {
|
||||
let server = responses::start_mock_server().await;
|
||||
|
||||
@@ -1753,7 +1753,7 @@ async fn turn_start_accepts_personality_override_v2() -> Result<()> {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn turn_start_accepts_multi_agent_mode_v2() -> Result<()> {
|
||||
async fn turn_start_ignores_deprecated_multi_agent_mode() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
@@ -1816,18 +1816,19 @@ async fn turn_start_accepts_multi_agent_mode_v2() -> Result<()> {
|
||||
.single_request()
|
||||
.message_input_texts("developer");
|
||||
assert!(developer_texts.iter().any(|text| {
|
||||
text.contains("<multi_agent_mode>")
|
||||
&& text.contains("Proactive multi-agent delegation is active.")
|
||||
}));
|
||||
assert!(!developer_texts.iter().any(|text| {
|
||||
text.contains("Do not spawn sub-agents unless the user explicitly asks for sub-agents")
|
||||
}));
|
||||
assert!(
|
||||
!developer_texts
|
||||
.iter()
|
||||
.any(|text| text.contains("Proactive multi-agent delegation is active."))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_multi_agent_mode_initializes_first_turn() -> Result<()> {
|
||||
async fn thread_start_ignores_deprecated_multi_agent_mode() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
@@ -1866,7 +1867,7 @@ async fn thread_start_multi_agent_mode_initializes_first_turn() -> Result<()> {
|
||||
multi_agent_mode,
|
||||
..
|
||||
} = to_response::<ThreadStartResponse>(thread_resp)?;
|
||||
assert_eq!(multi_agent_mode, MultiAgentMode::Proactive);
|
||||
assert_eq!(multi_agent_mode, MultiAgentMode::ExplicitRequestOnly);
|
||||
|
||||
let turn_req = mcp
|
||||
.send_turn_start_request(TurnStartParams {
|
||||
@@ -1894,71 +1895,20 @@ async fn thread_start_multi_agent_mode_initializes_first_turn() -> Result<()> {
|
||||
let developer_texts = response_mock
|
||||
.single_request()
|
||||
.message_input_texts("developer");
|
||||
assert!(developer_texts.iter().any(|text| {
|
||||
text.contains(MULTI_AGENT_MODE_OPEN_TAG)
|
||||
&& text
|
||||
.contains("Do not spawn sub-agents unless the user explicitly asks for sub-agents")
|
||||
}));
|
||||
assert!(
|
||||
developer_texts.iter().any(|text| {
|
||||
text.contains(MULTI_AGENT_MODE_OPEN_TAG)
|
||||
&& text.contains("Proactive multi-agent delegation is active.")
|
||||
}),
|
||||
"expected proactive multi-agent mode instructions in developer input, got {developer_texts:?}"
|
||||
!developer_texts
|
||||
.iter()
|
||||
.any(|text| text.contains("Proactive multi-agent delegation is active."))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_reports_multi_agent_mode() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let cases = [
|
||||
(
|
||||
BTreeMap::from([(Feature::MultiAgentV2, true)]),
|
||||
Some(MultiAgentMode::Proactive),
|
||||
MultiAgentMode::Proactive,
|
||||
),
|
||||
(
|
||||
BTreeMap::from([(Feature::MultiAgentV2, true)]),
|
||||
Some(MultiAgentMode::None),
|
||||
MultiAgentMode::None,
|
||||
),
|
||||
(
|
||||
BTreeMap::new(),
|
||||
Some(MultiAgentMode::Proactive),
|
||||
MultiAgentMode::Proactive,
|
||||
),
|
||||
(
|
||||
BTreeMap::from([(Feature::MultiAgentV2, true)]),
|
||||
None,
|
||||
MultiAgentMode::ExplicitRequestOnly,
|
||||
),
|
||||
];
|
||||
|
||||
for (features, requested_multi_agent_mode, expected_multi_agent_mode) in cases {
|
||||
let server = responses::start_mock_server().await;
|
||||
let codex_home = TempDir::new()?;
|
||||
create_config_toml(codex_home.path(), &server.uri(), "never", &features)?;
|
||||
|
||||
let mut mcp = TestAppServer::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
let thread_req = mcp
|
||||
.send_thread_start_request(ThreadStartParams {
|
||||
model: Some("mock-model".to_string()),
|
||||
multi_agent_mode: requested_multi_agent_mode,
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
let thread_resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(thread_req)),
|
||||
)
|
||||
.await??;
|
||||
let response = to_response::<ThreadStartResponse>(thread_resp)?;
|
||||
|
||||
assert_eq!(response.multi_agent_mode, expected_multi_agent_mode);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn turn_start_change_personality_mid_thread_v2() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
Reference in New Issue
Block a user