Repository navigation
Description
Describe the bug
On the OpenAI Chat Completions stream parser, a tool call that has already been buffered is discarded when the next line is data: [DONE] and no chunk has carried a finish_reason yet. The agent then continues 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 separate finish_reason: "tool_calls" chunk.
The same parser treats a closed connection differently: end-of-stream falls out of the tool-call loop and still emits the buffered call. [DONE], which is the normal terminal sentinel, leaves via break 'outer in response_to_streaming_message (crates/oi-kit-provider-types/src/formats/openai.rs) and never reaches that emit.
This is not #13637. That report is a text stream that ends with neither [DONE] nor finish_reason and is accepted as a completed turn. Here the stream does send [DONE], and the tool call is dropped.
To Reproduce
Feed these two SSE lines to response_to_streaming_message. No model is required.
data: {"id":"x","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_1","type":"function","function":{"name":"shell","arguments":"{\"command\":\"echo hi\"}"}}]},"finish_reason":null}]}
data: [DONE]
The parsed result contains no shell tool request.
Expected behavior
[DONE] should end tool-call accumulation and emit the call that was already buffered, the same way a naturally ended stream does. If the arguments are still incomplete, the existing argument-parse error should surface so the model can retry. The call should not disappear.
A stream that sends finish_reason: "tool_calls" and then [DONE] should keep working as it does today.
Screenshots
Not applicable. This is a parser behavior, reproduced from the stream fixture above on current main (03a343f).
Please provide the following information
- OS & Arch: Windows 11 x64 (the parser bug is not OS-specific)
- Interface: CLI, and any client using the OpenAI Chat Completions engine
- Version:
mainat03a343f - Extensions enabled: not relevant; the tool call never leaves the parser
- Provider & Model: custom provider,
"engine": "openai"
Additional context
I would like to fix this myself. Please leave it with me so it is not picked up by someone else. I will wait until the issue is Ready on the Goose Issues board before opening a pull request, and the change will stay within the direction above: treat [DONE] during tool-call accumulation as the end of the stream, not as a reason to discard the buffered call. A regression test should cover a complete tool delta followed by [DONE] with no finish_reason.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
four1er commentedon Nov 24, 2026
I am reproducing this now and preparing a PR:
data: [DONE]after a buffered tool-call delta should emit the buffered call instead of dropping it (same as the end-of-stream path inresponse_to_streaming_message). Will link the PR here shortly.xiaoyuCR7 commentedon Nov 24, 2026
@four1er Thanks for looking. I'm the reporter, and I already have the fix ready. I'm waiting to hear from a maintainer before opening the PR, since external PRs need the issue to be Ready. Please don't open a competing PR.
jbg commentedon Nov 30, 2026
Thanks to both contributors. The two patches make the same parser change, so let’s proceed with #13788, which was opened first. The scope is to emit buffered tool calls when
[DONE]arrives beforefinish_reason, preserve the existing parse error for incomplete arguments, and keep the normalfinish_reasonand text-only paths covered.fix(openai): emit buffered tool call on [DONE] (fixes aaif-goose#13785)…