Keep effective tool exposure in the registry (#36367)

## Why

`ToolExecutor::exposure()` describes a tool's preferred exposure, while the host
may apply step-specific policy when building a tool plan.

## What changed

- Store each runtime together with its effective exposure in `ToolRegistry`.
- Apply MCP, namespace, and collaboration-tool exposure overrides directly to
  registry entries instead of wrapping runtimes.
- Use the registry-owned exposure when building model-visible specs, deferred
  tool search, code-mode executors, and parallel-call support.

## Testing

- Cover that a hidden MCP tool remains routable but is not eligible for parallel
  tool calls.

GitOrigin-RevId: 1bc2760add8d993f477954269fa13681bfcc2444
This commit is contained in:
jif authored and copyberry committed 2026-07-31 17:24:33 +00:00
1 parent 287e1020ae
commit 775fb21d2a
11 files changed
+235 -269

No files matched your search

+3 -3
View File
@@ -84,15 +84,15 @@ pub(crate) struct ToolSuggestCandidates {
impl ToolRouter {
#[cfg(test)]
pub(crate) fn from_tools(
pub(crate) fn from_registry(
turn_context: &TurnContext,
tool_runtimes: Vec<Arc<dyn CoreToolRuntime>>,
registry: ToolRegistry,
hosted_specs: Vec<ToolSpec>,
tool_search_handler_cache: &ToolSearchHandlerCache,
) -> Self {
finalize_tool_router(
turn_context,
ToolRegistry::from_tools(tool_runtimes),
registry,
hosted_specs,
tool_search_handler_cache,
)