Repository navigation
fix(openai): emit buffered tool call on [DONE] (fixes #13785) - #13788
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 30, 2026
jbg
approved these changes
Nov 30, 2026
jbg
left a comment
Collaborator
There was a problem hiding this comment.
The parser now emits buffered tool calls before stopping at [DONE]. The regression tests cover fragmented arguments, incomplete arguments, a separate finish_reason frame, and text-only streams. I reviewed the diff against the agreed scope and checked the required CI results.
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
Fixes #13785.
On the OpenAI Chat Completions stream parser, a tool call that had already been buffered was discarded when the next line was
data: [DONE]and no chunk had carried afinish_reasonyet. The agent then continued as if the model produced no tool call. This affects every custom provider with"engine": "openai"that is not routed to the Responses API, including local servers and gateways that send a complete tool delta and then[DONE]without a separatefinish_reason: "tool_calls"chunk.Fix
In
response_to_streaming_message(crates/oi-kit-provider-types/src/formats/openai.rs),[DONE]no longerbreaks out of the outer loop and drops the buffered call. It now exits the tool-call accumulation loop first, emitting the buffered tool call (or surfacing the argument-parse error if the arguments are still incomplete), and then breaks out — without reading anything after[DONE].A stream that sends
finish_reason: "tool_calls"and then[DONE]keeps working as before, as does a plain text stream ending with[DONE].Tests
crates/oi-kit-provider-types:[DONE]after a complete buffered tool call emits it;[DONE]truncation;finish_reason: "tool_calls"+[DONE]unchanged; incomplete tool-call arguments surface the parse error; plain text stream +[DONE]unchanged. The repro test fails on the old code and passes with the fix.cargo test -p oi-kit-provider-types: 744 passed, 0 failed.cargo fmtandcargo clippy -D warningspass.Note: end-to-end verification against a live model / local OpenAI-compatible gateway was not possible in this environment; verification is via the offline SSE fixture from the issue.