Reserve the tool_search namespace for the search tool (#37188)

## What changed

- Remove namespace tools named `tool_search` before registering the built-in
  search tool, preventing them from sharing its model-visible surface.
- Record removed namespace tools as collisions so strict collision handling
  reports their qualified tool names.

## Testing

- Cover direct and deferred MCP tools that use the reserved namespace.
- Cover strict collision errors for both direct and deferred conflicts.

GitOrigin-RevId: 28fff918b4358a67b167467d92728fa545b951d7
This commit is contained in:
tongzhou wang authored and copyberry committed 2026-08-06 00:16:57 +00:00
1 parent 928bda82cf
commit 98da2c4499
2 files changed
+92 -1

No files matched your search

+17 -1
View File
@@ -342,7 +342,23 @@ pub(crate) fn finalize_tool_router(
})
{
if registry.remove(&tool_search_name).is_some() {
registry.record_collision(tool_search_name);
registry.record_collision(tool_search_name.clone());
}
// Special model tools own the namespace matching their wire identity, so
// regular namespace tools cannot advertise that same model-visible surface.
let conflicting_tool_names = registry
.entries()
.filter_map(|tool| {
let ToolSpec::Namespace(namespace) = tool.runtime.spec() else {
return None;
};
(namespace.name == tool_search_name.name).then(|| tool.runtime.tool_name())
})
.collect::<Vec<_>>();
for tool_name in conflicting_tool_names {
if registry.remove(&tool_name).is_some() {
registry.record_collision(tool_name);
}
}
append_tool_search_executor(turn_context, &mut registry, tool_search_handler_cache);
}