mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use captured step settings when spawning subagents (#46075)
## Why After a settings update during an active turn, spawned agents could inherit the turn's initial model and reasoning settings. Effort-only overrides could also be validated against the wrong model. ## What changed Build child configuration from the invoking step's captured model, effective reasoning effort, and reasoning summary in both multi-agent versions. Validate effort-only overrides against that captured model's supported reasoning levels. ## Testing Add regression coverage for spawning after an active-turn settings update in both multi-agent versions, including effort-only overrides. Update configuration tests to check captured settings and the model's default reasoning effort. GitOrigin-RevId: 068bdb744149048829cdaa68d254b62e96e6e6af
This commit is contained in:
1 parent
6749535c8f
commit
800d183e2d
9 files changed
+196
-27
No files matched your search
@@ -109,6 +109,8 @@ use test_case::test_case;
|
||||
use super::rmcp_client::remote_aware_environment_id;
|
||||
use super::rmcp_client::remote_aware_stdio_server_bin;
|
||||
|
||||
#[path = "step_settings/agent_spawn_tests.rs"]
|
||||
mod agent_spawn;
|
||||
mod code_mode_notifications;
|
||||
|
||||
const MODEL_A: &str = "step-settings-a";
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//! Spawned agents inherit the invoking step's model settings after active-turn updates.
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(false, None; "v1 inherits captured settings")]
|
||||
#[test_case(true, None; "v2 inherits captured settings")]
|
||||
#[test_case(false, Some(ReasoningEffort::Medium); "v1 validates effort against captured model")]
|
||||
#[test_case(true, Some(ReasoningEffort::Medium); "v2 validates effort against captured model")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn spawn_inherits_captured_settings_after_a_turn_update(
|
||||
multi_agent_v2: bool,
|
||||
requested_effort: Option<ReasoningEffort>,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut spawn_arguments = json!({ "message": "Complete the delegated task." });
|
||||
let namespace = if multi_agent_v2 {
|
||||
spawn_arguments["task_name"] = json!("worker");
|
||||
spawn_arguments["fork_turns"] = json!("none");
|
||||
"collaboration"
|
||||
} else {
|
||||
"multi_agent_v1"
|
||||
};
|
||||
if let Some(effort) = &requested_effort {
|
||||
spawn_arguments["reasoning_effort"] = json!(effort);
|
||||
}
|
||||
let response_mock = mount_sse_sequence(
|
||||
&server,
|
||||
vec![
|
||||
paused_response("resp-original", "pause-before-spawn"),
|
||||
sse(vec![
|
||||
ev_response_created("resp-spawn"),
|
||||
ev_function_call_with_namespace(
|
||||
"spawn-worker",
|
||||
namespace,
|
||||
"spawn_agent",
|
||||
&spawn_arguments.to_string(),
|
||||
),
|
||||
ev_completed("resp-spawn"),
|
||||
]),
|
||||
sse_completed("resp-first-completion"),
|
||||
sse_completed("resp-second-completion"),
|
||||
],
|
||||
)
|
||||
.await;
|
||||
// Child completion can trigger another parent request after the parent finishes.
|
||||
mount_sse_once(&server, sse_completed("resp-child-notification")).await;
|
||||
let test = step_settings_test()
|
||||
.with_config(move |config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Collab)
|
||||
.expect("enable collab");
|
||||
if multi_agent_v2 {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("enable V2");
|
||||
} else {
|
||||
config
|
||||
.features
|
||||
.disable(Feature::MultiAgentV2)
|
||||
.expect("disable V2");
|
||||
}
|
||||
for model in &mut config.model_catalog.as_mut().expect("model catalog").models {
|
||||
// An effort-only override must be validated against B, not the turn's initial A.
|
||||
model.supported_reasoning_levels = if model.slug == MODEL_B {
|
||||
vec![ReasoningEffort::Medium, ReasoningEffort::High]
|
||||
} else {
|
||||
vec![ReasoningEffort::Low]
|
||||
}
|
||||
.into_iter()
|
||||
.map(|effort| ReasoningEffortPreset {
|
||||
description: effort.to_string(),
|
||||
effort,
|
||||
})
|
||||
.collect();
|
||||
model.supports_reasoning_summary_parameter = true;
|
||||
model.use_responses_lite = false;
|
||||
}
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let mut created_threads = test.thread_manager.subscribe_thread_created();
|
||||
let request = start_paused_turn(&test.codex).await?;
|
||||
apply_turn_settings(
|
||||
&test.codex,
|
||||
&request.turn_id,
|
||||
TurnSettingsUpdate {
|
||||
model: Some(MODEL_B.to_string()),
|
||||
effort: Some(Some(ReasoningEffort::High)),
|
||||
summary: Some(ReasoningSummary::Detailed),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
answer_paused_turn(&test.codex, &request.turn_id).await?;
|
||||
|
||||
let child_thread_id = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(/*secs*/ 10),
|
||||
created_threads.recv(),
|
||||
)
|
||||
.await??;
|
||||
let child_thread = test.thread_manager.get_thread(child_thread_id).await?;
|
||||
for thread in [child_thread.as_ref(), test.codex.as_ref()] {
|
||||
wait_for_event(thread, |event| matches!(event, EventMsg::TurnComplete(_))).await;
|
||||
}
|
||||
|
||||
let expected_effort = requested_effort.unwrap_or(ReasoningEffort::High);
|
||||
let requests = response_mock.requests();
|
||||
let child_request = requests
|
||||
.iter()
|
||||
.find(|request| request.header("thread-id") == Some(child_thread_id.to_string()))
|
||||
.expect("child should make a model request");
|
||||
assert_eq!(
|
||||
request_settings(child_request),
|
||||
json!({
|
||||
"model": MODEL_B,
|
||||
"reasoning": { "effort": expected_effort, "summary": "detailed" },
|
||||
"service_tier": null,
|
||||
})
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -67,6 +67,7 @@ use tokio::time::Instant;
|
||||
use tokio::time::sleep;
|
||||
use tokio::time::timeout;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_test::internal::MockWriter;
|
||||
use wiremock::Mock;
|
||||
use wiremock::MockServer;
|
||||
@@ -2212,6 +2213,11 @@ async fn multi_agent_v2_spawn_sends_agent_message_to_child(
|
||||
.with_writer(MockWriter::new(output))
|
||||
.finish();
|
||||
let _guard = tracing::subscriber::set_default(subscriber);
|
||||
// Keep two dispatchers alive so a parallel test that first registers a communication
|
||||
// callsite without a subscriber cannot globally disable it for our capturing subscriber.
|
||||
let _parallel_dispatch = tracing::Dispatch::new(
|
||||
tracing_subscriber::registry().with(tracing_subscriber::filter::LevelFilter::OFF),
|
||||
);
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let message = if plaintext {
|
||||
|
||||
Reference in new issue
Block a user