Omit native multi-agent guidance when native tools are disabled (#59732)

## Why

Multi-agent V2 still supplied native tool usage guidance when native tools were disabled, leaving instructions for unavailable tools in model requests.

## What changed

Skip bundled and model catalog role guidance for both root agents and subagents when `disable_native_tools` is enabled. Preserve explicitly configured usage hints.

## Testing

Add coverage for omitted bundled and catalog guidance and preserved configured hints with native tools disabled. Update the request snapshot and assert that spawned agents do not receive native tool call guidance.

GitOrigin-RevId: 6f2facabc95e78cbf64af19636a4daf488bbcc51
This commit is contained in:
Won Park
2026-11-05 20:43:36 +00:00
committed by copyberry
parent 2e58636d16
commit c8a1109fa7
5 changed files with 35 additions and 28 deletions
+24 -3
View File
@@ -12893,8 +12893,11 @@ max_concurrent_threads_per_session = 17
assert!(usage_hints.root.is_none() && usage_hints.subagent.is_none());
}
#[test]
fn multi_agent_v2_model_override_exposure_preserves_configured_usage_hints() {
#[test_case::test_case(false; "native_tools")]
#[test_case::test_case(true; "native_tools_disabled")]
fn multi_agent_v2_model_override_exposure_preserves_configured_usage_hints(
disable_native_tools: bool,
) {
let config_toml = toml::from_str(
r###"[features.multi_agent_v2]
enabled = true
@@ -12905,7 +12908,8 @@ expose_spawn_agent_model_overrides = true
)
.expect("multi-agent v2 config should parse");
let config = resolve_multi_agent_v2_config(&config_toml);
let mut config = resolve_multi_agent_v2_config(&config_toml);
config.disable_native_tools = disable_native_tools;
assert!(config.expose_spawn_agent_model_overrides);
assert_eq!(
config.root_agent_usage_hint_text.as_deref(),
@@ -12933,6 +12937,23 @@ expose_spawn_agent_model_overrides = true
);
}
#[test]
fn multi_agent_v2_disabled_native_tools_omit_default_roles() {
let mut config = resolve_multi_agent_v2_config(&ConfigToml::default());
config.disable_native_tools = true;
let mut messages = ResolvedModelMessages::bundled().multi_agent();
for catalog_override in [false, true] {
if catalog_override {
messages.root = ResolvedMessage::Catalog("Catalog root base.");
messages.subagent = ResolvedMessage::Catalog("Catalog subagent base.");
}
let usage_hints = resolve_usage_hints(
&config, messages, /*omit_update_plan_instructions*/ false,
);
assert_eq!((usage_hints.root, usage_hints.subagent), (None, None));
}
}
#[test]
fn multi_agent_v2_exposes_model_overrides_by_default() {
let config_toml =
@@ -52,6 +52,9 @@ pub(crate) fn resolve_usage_hints(
if base.is_empty() {
return None;
}
if config.disable_native_tools {
return None;
}
Some(MultiAgentRoleInstructions::Composed {
base: base.to_owned(),
marked: message.catalog_override().is_some(),