fix: prevent empty tool_call delta from overwriting accumulated call_…#341
Open
lao-der wants to merge 1 commit into
Open
fix: prevent empty tool_call delta from overwriting accumulated call_…#341lao-der wants to merge 1 commit into
lao-der wants to merge 1 commit into
Conversation
…id/name When upstream Chat Completions models (e.g. GLM, qwen via DashScope) return empty strings for id/name in tool_call delta chunks after the first one, the streaming accumulation logic in push_tool_call_delta was overwriting previously stored call_id/name with those empty values. This caused response.output_item.done and response.completed to carry empty call_id and name, leading Codex to reject the tool call with "unsupported call:". Guard both id and name assignments with non-empty checks so that empty deltas are treated as "continue previous value" rather than "clear". Add regression test covering subsequent chunks with empty id/name.
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.
Summary
Fix streaming tool call conversion where
call_idandnameare overwritten by empty delta chunks.In
push_tool_call_delta, bothid/call_idandnameassignments lacked empty-string protection. When upstream models (e.g. GLM, qwen via DashScope/Aliyun) return emptyidandnamein tool_call delta chunks after the first one, the accumulated values are overwritten with empty strings. This causesresponse.output_item.doneandresponse.completedto carry emptycall_idandname, leading Codex to reject the tool call withunsupported call:.This PR adds non-empty checks for both
idandnameassignments, so that empty deltas are treated as "continue previous value" rather than "clear". Verified locally that streaming tool calls work correctly after the fix.Related Issue
Fixes #340
Screenshots
N/A (no UI changes)
call_idandnameempty inoutput_item.doneChecklist
cargo clippypassescargo testpasses