From 679de088a30d3e793f8c4115ca81bb06ec53e5f7 Mon Sep 17 00:00:00 2001 From: Friel Date: Sat, 4 Apr 2026 01:12:31 +0000 Subject: [PATCH] Keep max-depth collab tool schemas stable --- codex-rs/core/src/agent/control.rs | 8 +------- codex-rs/core/src/codex.rs | 7 ------- .../core/src/tools/handlers/multi_agents_common.rs | 8 +------- codex-rs/core/src/tools/handlers/multi_agents_tests.rs | 10 ++++++++++ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/codex-rs/core/src/agent/control.rs b/codex-rs/core/src/agent/control.rs index 9358319b90..31cdf4400e 100644 --- a/codex-rs/core/src/agent/control.rs +++ b/codex-rs/core/src/agent/control.rs @@ -419,16 +419,10 @@ impl AgentControl { async fn resume_single_agent_from_rollout( &self, - mut config: crate::config::Config, + config: crate::config::Config, thread_id: ThreadId, session_source: SessionSource, ) -> CodexResult { - if let SessionSource::SubAgent(SubAgentSource::ThreadSpawn { depth, .. }) = &session_source - && *depth >= config.agent_max_depth - { - let _ = config.features.disable(Feature::SpawnCsv); - let _ = config.features.disable(Feature::Collab); - } let state = self.upgrade()?; let mut reservation = self.state.reserve_spawn_slot(config.agent_max_threads)?; let (session_source, agent_metadata) = match session_source { diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 582424c798..8bf5ab0216 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -496,13 +496,6 @@ impl Codex { ); } - if let SessionSource::SubAgent(SubAgentSource::ThreadSpawn { depth, .. }) = session_source - && depth >= config.agent_max_depth - { - let _ = config.features.disable(Feature::SpawnCsv); - let _ = config.features.disable(Feature::Collab); - } - if config.features.enabled(Feature::JsRepl) && let Err(err) = resolve_compatible_node(config.js_repl_node_path.as_deref()).await { diff --git a/codex-rs/core/src/tools/handlers/multi_agents_common.rs b/codex-rs/core/src/tools/handlers/multi_agents_common.rs index dd68465a7f..7d56ad3039 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_common.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_common.rs @@ -8,7 +8,6 @@ use crate::models_manager::manager::RefreshStrategy; use crate::tools::context::FunctionToolOutput; use crate::tools::context::ToolOutput; use crate::tools::context::ToolPayload; -use codex_features::Feature; use codex_protocol::AgentPath; use codex_protocol::ThreadId; use codex_protocol::models::BaseInstructions; @@ -264,12 +263,7 @@ pub(crate) fn apply_spawn_agent_runtime_overrides( Ok(()) } -pub(crate) fn apply_spawn_agent_overrides(config: &mut Config, child_depth: i32) { - if child_depth >= config.agent_max_depth && !config.features.enabled(Feature::MultiAgentV2) { - let _ = config.features.disable(Feature::SpawnCsv); - let _ = config.features.disable(Feature::Collab); - } -} +pub(crate) fn apply_spawn_agent_overrides(_config: &mut Config, _child_depth: i32) {} pub(crate) async fn apply_requested_spawn_agent_model_overrides( session: &Session, diff --git a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs index 9a71144cce..3fab2df0fd 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs @@ -1762,6 +1762,10 @@ async fn spawn_agent_allows_depth_up_to_configured_max_depth() { let mut config = (*turn.config).clone(); config.agent_max_depth = DEFAULT_AGENT_MAX_DEPTH + 1; + config + .features + .enable(Feature::SpawnCsv) + .expect("test config should allow spawn_csv"); turn.config = Arc::new(config); turn.session_source = SessionSource::SubAgent(SubAgentSource::ThreadSpawn { parent_thread_id: session.conversation_id, @@ -1785,6 +1789,12 @@ async fn spawn_agent_allows_depth_up_to_configured_max_depth() { let result: SpawnAgentResult = serde_json::from_str(&content).expect("spawn_agent result should be json"); assert!(!result.agent_id.is_empty()); + let child_thread = manager + .get_thread(parse_agent_id(&result.agent_id)) + .await + .expect("spawned max-depth child thread should exist"); + assert!(child_thread.enabled(Feature::Collab)); + assert!(child_thread.enabled(Feature::SpawnCsv)); assert!( result .nickname