Skip to content

Commit c37f743

Browse files
authored
Gate multi-agent v2 tools independently of collab (#20246)
## Why `multi_agents_v2` is meant to be independently gated from the older `collab` feature. The tool registry still treated the collaboration-style agent tools as `collab`-only, so enabling `multi_agents_v2` without `collab` omitted the v2 agent tools. Review and guardian sub-sessions also need to keep agent spawning disabled even when the outer session has `multi_agents_v2` enabled. ## What changed - Include the collab-backed agent tools when either `multi_agents_v2` or `collab` is enabled. - Explicitly disable `multi_agents_v2` for review and guardian review sub-sessions, matching the existing `spawn_csv` and `collab` restrictions. - Add a registry test that enables `multi_agents_v2`, disables `collab`, and verifies the v2 agent tools are present while legacy `send_input` and `resume_agent` remain hidden. ## Testing - Added `test_build_specs_multi_agent_v2_does_not_require_collab_feature`.
1 parent a73403a commit c37f743

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

codex-rs/core/src/guardian/review_session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ pub(crate) fn build_guardian_review_session_config(
931931
for feature in [
932932
Feature::SpawnCsv,
933933
Feature::Collab,
934+
Feature::MultiAgentV2,
934935
Feature::CodexHooks,
935936
Feature::Apps,
936937
Feature::Plugins,

codex-rs/core/src/tasks/review.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async fn start_review_conversation(
110110
}
111111
let _ = sub_agent_config.features.disable(Feature::SpawnCsv);
112112
let _ = sub_agent_config.features.disable(Feature::Collab);
113+
let _ = sub_agent_config.features.disable(Feature::MultiAgentV2);
113114

114115
// Set explicit review rubric for the sub-agent
115116
sub_agent_config.base_instructions = Some(crate::REVIEW_PROMPT.to_string());

codex-rs/tools/src/tool_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl ToolsConfig {
143143
let include_apply_patch_tool = features.enabled(Feature::ApplyPatchFreeform);
144144
let include_code_mode = features.enabled(Feature::CodeMode);
145145
let include_code_mode_only = include_code_mode && features.enabled(Feature::CodeModeOnly);
146-
let include_collab_tools = features.enabled(Feature::Collab);
147146
let include_goal_tools = features.enabled(Feature::Goals);
148147
let include_multi_agent_v2 = features.enabled(Feature::MultiAgentV2);
148+
let include_collab_tools = include_multi_agent_v2 || features.enabled(Feature::Collab);
149149
let include_agent_jobs = features.enabled(Feature::SpawnCsv);
150150
let include_search_tool =
151151
model_info.supports_search_tool && features.enabled(Feature::ToolSearch);

codex-rs/tools/src/tool_registry_plan_tests.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,46 @@ fn test_build_specs_multi_agent_v2_uses_task_names_and_hides_resume() {
385385
assert_lacks_tool_name(&tools, "resume_agent");
386386
}
387387

388+
#[test]
389+
fn test_build_specs_multi_agent_v2_does_not_require_collab_feature() {
390+
let model_info = model_info();
391+
let mut features = Features::with_defaults();
392+
features.disable(Feature::Collab);
393+
features.enable(Feature::MultiAgentV2);
394+
assert!(!features.enabled(Feature::Collab));
395+
let available_models = Vec::new();
396+
let tools_config = ToolsConfig::new(&ToolsConfigParams {
397+
model_info: &model_info,
398+
available_models: &available_models,
399+
features: &features,
400+
image_generation_tool_auth_allowed: true,
401+
web_search_mode: Some(WebSearchMode::Cached),
402+
session_source: SessionSource::Cli,
403+
permission_profile: &PermissionProfile::Disabled,
404+
windows_sandbox_level: WindowsSandboxLevel::Disabled,
405+
});
406+
let (tools, _) = build_specs(
407+
&tools_config,
408+
/*mcp_tools*/ None,
409+
/*deferred_mcp_tools*/ None,
410+
&[],
411+
);
412+
413+
assert_contains_tool_names(
414+
&tools,
415+
&[
416+
"spawn_agent",
417+
"send_message",
418+
"followup_task",
419+
"wait_agent",
420+
"close_agent",
421+
"list_agents",
422+
],
423+
);
424+
assert_lacks_tool_name(&tools, "send_input");
425+
assert_lacks_tool_name(&tools, "resume_agent");
426+
}
427+
388428
#[test]
389429
fn test_build_specs_enable_fanout_enables_agent_jobs_and_collab_tools() {
390430
let model_info = model_info();

0 commit comments

Comments
 (0)