Repository navigation
feat(openresponses): accept namespace tools - #13098
Open
coffeerunhobby wants to merge 1 commit into
Open
coffeerunhobby wants to merge 1 commit into
coffeerunhobby wants to merge 1 commit into
Conversation
Codex and other Responses clients send each MCP server's tools as one
{"type": "namespace", "name": ..., "tools": [...]} entry and route a
returned call by its (namespace, name) pair. convertORToolsToOpenAIFormat
kept only function tools, so the model never saw an MCP tool.
Flatten each namespace member to ns_{namespace}___{name}, the form
llama.cpp's server uses, for the model and the grammar. Earlier
function_call items that carry a namespace are flattened the same way,
both in the input and when a stored response is replayed. Returned
function_call items are split back into namespace and name where
outputs leave: buildORResponse and normalizeORStreamEvent, which covers
streaming, background, WebSocket and stored responses. The name decodes
by itself, so no per-request state is needed; a namespace must not
contain "___".
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Cristi An <c4xp@msn.com>
Contributor
Author
|
I almost forgot: for context, all others are adding the same support for namespace tools :) We are just lucky we see around the corner:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Codex and other Responses API clients send each MCP server's tools as one namespace entry,
{"type": "namespace", "name": "mcp__docs", "tools": [...]}, and route a returned call by its(namespace, name)pair.convertORToolsToOpenAIFormatkeeps only function tools, so the modelnever sees an MCP tool, and Codex reports that the tools are not available.
This PR flattens each namespace member to
ns_{namespace}___{name}, the form llama.cpp's serveruses (ggml-org/llama.cpp#31568). That flat name goes to the model and the grammar. A
function_callitem that carries anamespacein the input, or in a replayed stored response, isflattened the same way. Returned
function_callitems are split back intonamespaceandnamewhere outputs leave: in
buildORResponseand innormalizeORStreamEvent. That coversnon-streaming, streaming, background, WebSocket and stored responses.
Notes for Reviewers
llama.cpp's: a namespace does not contain
___.matched against LocalAI's server-side MCP tools (which are injected as plain
functiontools undertheir own names), even if the names coincide, so a client-declared tool cannot trigger a server tool.
tool_searchandadditional_tools(tools loaded during a turn);tool_choicenaming a namespaced function;toolsonschema.ORFunctionTool,namespaceonschema.ORItemParam). Runningswag initon current master also picks up unrelatedlocked/lockedReasondrift, which is left out.Tests:
go test ./core/http/endpoints/openresponses/ ./core/schema/(87/87 and 83/83). The newspecs cover the tool conversion, replaying a namespaced call, and a streamed call coming back with
its namespace in
output_item.added,output_item.doneandresponse.completed. They fail withthe change reverted.
Signed commits