Centralize Guardian classification of multi-agent tool calls (#57455)

## What changed

Add `GuardianScope::for_multi_agent_tool` and use it for both tool review requirements and asynchronous scoring. Classify `spawn_agent`, `send_message`, `followup_task`, and `interrupt_agent` as native tools when they match the configured namespace, accepting default namespace spellings when none is configured. Keep review enablement checks at each call site.

GitOrigin-RevId: 9180ccdc629532f6c171d899dc5881e15b447141
This commit is contained in:
jif
2026-10-27 13:55:51 +00:00
committed by copyberry
parent 6a6e2fb1f0
commit 90de7b92b6
3 changed files with 29 additions and 16 deletions
@@ -77,21 +77,16 @@ impl GuardianV2Extension {
GuardianScope::for_mcp_connector(&info.server_name, info.connector_id.as_deref())
})
.or_else(|| {
if guardian_config.review_multi_agent_calls
&& match guardian_config.multi_agent_namespace.as_deref() {
Some(namespace) => input.tool_name.namespace.as_deref() == Some(namespace),
None => input.tool_name.is_default_namespace(),
}
&& matches!(
input.tool_name.name.as_str(),
"spawn_agent" | "send_message" | "followup_task" | "interrupt_agent"
if guardian_config.review_multi_agent_calls {
GuardianScope::for_multi_agent_tool(
input.tool_name,
guardian_config.multi_agent_namespace.as_deref(),
)
{
Some(GuardianScope::NativeTool)
} else {
GuardianScope::for_tool(input.tool_name)
None
}
});
})
.or_else(|| GuardianScope::for_tool(input.tool_name));
// Model policies review nested actions; the Code Mode wrapper leaves their scores alone.
// The legacy all-tools policy still scores wrappers through `other_tools`.
if scope.is_none()