Support custom tools in namespaces (#36857)

## What changed

- Allow namespace tool specs to contain custom freeform tools alongside function tools.
- Include namespaced custom tools in deferred tool search and expose them to code mode with names such as `editor__apply_patch`.
- Route custom payloads to matching extension tools while preserving function-only payload validation.

## Testing

- Add serialization, tool search, code-mode definition, and end-to-end dispatch coverage for namespaced custom tools.

GitOrigin-RevId: be64d35f6ae54685c5a9fcf45a732320742ea7e5
This commit is contained in:
rka-oai authored and copyberry committed 2026-08-04 08:28:43 +00:00
1 parent 12288240b4
commit d4fb78bfc5
12 files changed
+409 -28

No files matched your search

+19 -5
View File
@@ -43,9 +43,15 @@ impl ToolSearchInfo {
namespace.description = default_namespace_description(&namespace.name);
}
for tool in &mut namespace.tools {
let ResponsesApiNamespaceTool::Function(tool) = tool;
tool.defer_loading = Some(true);
tool.output_schema = None;
match tool {
ResponsesApiNamespaceTool::Function(tool) => {
tool.defer_loading = Some(true);
tool.output_schema = None;
}
ResponsesApiNamespaceTool::Custom(tool) => {
tool.defer_loading = Some(true);
}
}
}
LoadableToolSpec::Namespace(namespace)
}
@@ -73,8 +79,16 @@ fn default_tool_search_text(spec: &ToolSpec) -> String {
push_search_part(&mut parts, namespace.name.clone());
push_search_part(&mut parts, namespace.description.clone());
for tool in &namespace.tools {
let ResponsesApiNamespaceTool::Function(tool) = tool;
append_function_search_text(tool, &mut parts);
match tool {
ResponsesApiNamespaceTool::Function(tool) => {
append_function_search_text(tool, &mut parts);
}
ResponsesApiNamespaceTool::Custom(tool) => {
push_search_part(&mut parts, tool.name.clone());
push_search_part(&mut parts, tool.description.clone());
push_search_part(&mut parts, tool.format.syntax.clone());
}
}
}
}
ToolSpec::ToolSearch { description, .. } => {