fix(proxy): preserve streaming tool identity for strict clients - #13
Open
guguguc wants to merge 1 commit into
Open
fix(proxy): preserve streaming tool identity for strict clients#13guguguc wants to merge 1 commit into
guguguc wants to merge 1 commit into
Conversation
Upstream OpenAI chat completions streams can emit null id/name fields on tool_calls argument deltas. Strict streaming clients (e.g. dsh) treat null as an override and end up calling an empty tool name. Filter those fields out while passing the stream through, keeping the tool identity set on the first chunk.
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.
Problem
Streaming clients like
@deepseek-ai/dshfailed to call tools when routed through the ocgo proxy (error:unknown tool ""/SSE stream ended without [DONE]).The upstream OpenAI
chat/completionsstream emitsid/nameon the firsttool_callschunk, then"id":null,"name":nullon subsequent argument deltas. Strict clients parse each delta with a!== undefinedcheck and treatnullas an override, wiping out the tool identity./v1/chat/completionsis a pure passthrough (io.Copy) for non-Anthropic-endpoint models, so the nulls reached clients untouched.Fix
idandfunction.namefields out oftool_callsdeltas while streaming (OpenAI spec only requires them on the first chunk).io.Copy, ensuringdata: [DONE]is always forwarded (readSSEpreviously swallowed it, causing clients to wait for a terminator that never came).[DONE]forwarding.Test plan
Verified by curling the proxy with a streaming tool-call request: the tool name is retained and the stream terminates with
data: [DONE].