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
@@ -94,7 +94,7 @@ async fn handle_spawn_agent(
|
||||
.await;
|
||||
let prepared = prepare_agent_spawn_config(
|
||||
&session,
|
||||
turn.as_ref(),
|
||||
step_context.as_ref(),
|
||||
SpawnConfigOptions {
|
||||
version: SpawnConfigVersion::V1,
|
||||
full_history_fork: args.fork_context,
|
||||
|
||||
@@ -14,6 +14,8 @@ use crate::init_state_db;
|
||||
use crate::local_agent_graph_store_from_state_db;
|
||||
use crate::session::step_context::StepContext;
|
||||
use crate::session::tests::make_session_and_context;
|
||||
use crate::session::tests::update_selected_settings_for_test;
|
||||
use crate::session::tests::update_turn_settings_for_test;
|
||||
use crate::session::turn_context::TurnContext;
|
||||
use crate::session_prefix::format_inter_agent_completion_message;
|
||||
use crate::thread_manager::thread_store_from_config;
|
||||
@@ -37,6 +39,7 @@ use codex_models_manager::manager::StaticModelsManager;
|
||||
use codex_protocol::AgentPath;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::config_types::ApprovalsReviewer;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use codex_protocol::config_types::ServiceTier;
|
||||
use codex_protocol::config_types::ShellEnvironmentPolicy;
|
||||
use codex_protocol::items::TurnItem;
|
||||
@@ -4405,7 +4408,9 @@ async fn tool_handlers_cascade_close_and_resume_and_keep_explicitly_closed_subtr
|
||||
#[test_case::test_case(false; "inactive_parent")]
|
||||
#[test_case::test_case(true; "active_parent")]
|
||||
#[tokio::test]
|
||||
async fn build_agent_spawn_config_uses_turn_context_values(parent_enabled: bool) {
|
||||
async fn build_agent_spawn_config_uses_captured_step_settings_and_turn_context_values(
|
||||
parent_enabled: bool,
|
||||
) {
|
||||
fn pick_allowed_sandbox_policy(
|
||||
permissions: &crate::config::Permissions,
|
||||
base: SandboxPolicy,
|
||||
@@ -4430,10 +4435,18 @@ async fn build_agent_spawn_config_uses_turn_context_values(parent_enabled: bool)
|
||||
}
|
||||
|
||||
let (_session, mut turn) = make_session_and_context().await;
|
||||
update_turn_settings_for_test(&mut turn, |settings| {
|
||||
update_selected_settings_for_test(settings, |selected| {
|
||||
selected.collaboration_mode.settings.model = "stale-turn-model".to_string();
|
||||
selected.collaboration_mode.settings.reasoning_effort = Some(ReasoningEffort::Low);
|
||||
});
|
||||
Arc::make_mut(&mut settings.model_info).slug = "stale-turn-model".to_string();
|
||||
settings.reasoning_summary = ReasoningSummary::Concise;
|
||||
});
|
||||
let base_instructions = BaseInstructions {
|
||||
text: "base".to_string(),
|
||||
provenance: Some(BaseInstructionsProvenance::Model {
|
||||
model: turn.model_info().slug.clone(),
|
||||
model: "captured-step-model".to_string(),
|
||||
}),
|
||||
};
|
||||
turn.developer_instructions = Some("dev".to_string());
|
||||
@@ -4495,13 +4508,30 @@ async fn build_agent_spawn_config_uses_turn_context_values(parent_enabled: bool)
|
||||
.get_or_insert_default()
|
||||
.guidance_message = Some("Parent model's resolved guidance.".to_string());
|
||||
|
||||
let config = build_agent_spawn_config(&base_instructions, &turn).expect("spawn config");
|
||||
let mut step_context = StepContext::for_test(Arc::new(turn));
|
||||
let settings = Arc::make_mut(
|
||||
&mut Arc::get_mut(&mut step_context)
|
||||
.expect("step context should not be shared")
|
||||
.settings,
|
||||
);
|
||||
update_selected_settings_for_test(settings, |selected| {
|
||||
selected.collaboration_mode.settings.model = "captured-step-model".to_string();
|
||||
selected.collaboration_mode.settings.reasoning_effort = None;
|
||||
});
|
||||
let model_info = Arc::make_mut(&mut settings.model_info);
|
||||
model_info.slug = "captured-step-model".to_string();
|
||||
model_info.default_reasoning_level = Some(ReasoningEffort::High);
|
||||
settings.reasoning_summary = ReasoningSummary::Detailed;
|
||||
|
||||
let turn = step_context.turn.as_ref();
|
||||
let config =
|
||||
build_agent_spawn_config(&base_instructions, step_context.as_ref()).expect("spawn config");
|
||||
expected.base_instructions_provenance = base_instructions.provenance.clone();
|
||||
expected.base_instructions = Some(base_instructions.text);
|
||||
expected.model = Some(turn.model_info().slug.clone());
|
||||
expected.model = Some("captured-step-model".to_string());
|
||||
expected.model_provider = turn.provider.info().clone();
|
||||
expected.model_reasoning_effort = turn.reasoning_effort().cloned();
|
||||
expected.model_reasoning_summary = Some(turn.reasoning_summary());
|
||||
expected.model_reasoning_effort = Some(ReasoningEffort::High);
|
||||
expected.model_reasoning_summary = Some(ReasoningSummary::Detailed);
|
||||
expected.developer_instructions = turn.developer_instructions.clone();
|
||||
#[allow(deprecated)]
|
||||
{
|
||||
|
||||
@@ -129,7 +129,7 @@ async fn handle_spawn_agent(
|
||||
let child_depth = next_thread_spawn_depth(&session_source);
|
||||
let prepared = prepare_agent_spawn_config(
|
||||
&session,
|
||||
turn.as_ref(),
|
||||
step_context.as_ref(),
|
||||
SpawnConfigOptions {
|
||||
version: SpawnConfigVersion::V2,
|
||||
full_history_fork: matches!(fork_mode, Some(SpawnAgentForkMode::FullHistory)),
|
||||
|
||||
Reference in new issue
Block a user