Keep agent concurrency guidance when native tools are disabled (#62864)

## Why

Disabling native multi-agent tools also dropped the default guidance about
how many agents can be active in a session. That limit still matters for
agents running on a host that handles turn admission.

## What changed

When `multi_agent_v2.disable_native_tools` is set, root agents and
subagents receive only the configured
`multi_agent_v2.max_concurrent_threads_per_session` in their default role
guidance. Explicit role overrides retain precedence, and empty role text
still suppresses the guidance.

## Testing

Cover both roles with bundled and catalog-provided role text. Update the
request snapshots for explicit and proactive delegation to show the
concurrency hint with native tools hidden.

GitOrigin-RevId: e940e7a7886b69888002307c021607b19bb87cd0
This commit is contained in:
rhan-oai
2026-11-20 23:44:47 +00:00
committed by copyberry
parent 8ecb4c9d0f
commit 663358f98d
9 changed files with 45 additions and 19 deletions
@@ -22,6 +22,8 @@ pub struct AgentTurnAdmissionRequest {
/// A submitted turn can be denied after its input was accepted. Core records that
/// input and reports the error through the ordinary turn lifecycle.
/// Hosts own remote retries, abandoned acquisitions and worker-loss recovery.
/// Default hosted roles advertise `multi_agent_v2.max_concurrent_threads_per_session`.
/// Hosts should set it to their admission limit or override the role text.
pub trait AgentTurnAdmission: Send + Sync {
fn admit_turn(
&self,
+9 -2
View File
@@ -13115,9 +13115,10 @@ expose_spawn_agent_model_overrides = true
}
#[test]
fn multi_agent_v2_disabled_native_tools_omit_default_roles() {
fn multi_agent_v2_disabled_native_tools_keep_only_concurrency() {
let mut config = resolve_multi_agent_v2_config(&ConfigToml::default());
config.disable_native_tools = true;
config.max_concurrent_threads_per_session = 17;
let mut messages = ResolvedModelMessages::bundled().multi_agent();
for catalog_override in [false, true] {
if catalog_override {
@@ -13127,7 +13128,13 @@ fn multi_agent_v2_disabled_native_tools_omit_default_roles() {
let usage_hints = resolve_usage_hints(
&config, messages, /*omit_update_plan_instructions*/ false,
);
assert_eq!((usage_hints.root, usage_hints.subagent), (None, None));
let expected = Some(
crate::context::MultiAgentRoleInstructions::concurrency_only(
/*max_concurrency*/ 17,
),
);
assert_eq!(usage_hints.root, expected);
assert_eq!(usage_hints.subagent, expected);
}
}
+3 -1
View File
@@ -55,7 +55,9 @@ pub(crate) fn resolve_usage_hints(
return None;
}
if config.disable_native_tools {
return None;
return Some(MultiAgentRoleInstructions::concurrency_only(
config.max_concurrent_threads_per_session,
));
}
Some(MultiAgentRoleInstructions::Composed {
base: base.to_owned(),