Repository navigation
server : implement namespaced tools in responses API (rebase of #23235) - #31568
Open
CanadaOrNaw wants to merge 3 commits into
Open
CanadaOrNaw wants to merge 3 commits into
CanadaOrNaw wants to merge 3 commits into
Conversation
…amespace tests Master's existing conversion tests expect non-function Responses tools (including a namespace without a tools array) to be skipped, not to fail the request. Warn-and-skip instead of throwing, matching that contract. Add test-chat coverage: namespace flattening, function_call input items with a namespace, and the flatten/split round-trip.
OpenAI Responses SSE events carry a monotonically increasing sequence_number. llama.cpp omitted it, and strict Responses clients fail every streamed turn with a decode error. Assign numbers at the stream writer, the one place every chunk of a streamed response passes, so numbering is monotonic across partial and final results.
|
Hi @CanadaOrNaw, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
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.
Overview
Supersedes #23235 (draft, stale since May; the original implementation commit by @aldehir is preserved as the first commit of this branch with authorship intact). Fixes #23229.
Two changes make the Responses API work with clients that group tools in namespaces (Codex CLI, Muse, MCP hosts):
type: "namespace"tools are flattened tons_{namespace}___{tool_name}for the model, and thenamespacefield is restored on returnedfunction_callitems (non-streaming, streaming final, and streaming partial paths). Namespacedfunction_callinput items flatten the same way.sequence_number: every streamed Responses SSE event now carries a monotonically increasingsequence_number, assigned at the stream writer so it stays monotonic across partial and final chunks. Strict Responses clients reject every streamed turn without it.Follow-up commit on top of the original: malformed namespace entries (missing name, missing/non-array
tools, missing inner name) now warn-and-skip like other non-function Responses tools instead of failing the request, matching the existing conversion tests on master.Additional information
Tests:
test-chat: new cases for namespace flattening, namespacedfunction_callinput items, and the flatten/split round-trip. All tests pass.function_callwithnamespacerestored (streaming and non-streaming); namespaced call history round-trips.Credit: original implementation by @aldehir in #23235.
Requirements