fix: treat DONE-less SSE close after finish_reason as clean EOF (#76)#77
Merged
Conversation
Some providers (MiniMax confirmed in the field, yoyo-evolve#612) close the SSE connection without the OpenAI-standard `data: [DONE]` terminator, surfacing as reqwest_eventsource::Error::StreamEnded. The compat reader already tolerated the identical close when it arrived as a graceful None, but errored on StreamEnded — after the complete response had already streamed to the caller. Guard: track saw_finish_reason; StreamEnded after a finish_reason is a completed response (break, clean finish); StreamEnded with NO finish_reason is genuine mid-stream truncation and stays an error, so retry semantics remain honest for real drops. Tests: wiremock SSE with deltas + finish_reason then body end without [DONE] → clean completion with accumulated content and StopReason::Stop; sibling close before any finish_reason → still Err. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 20, 2026
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.
Fixes #76 — implements exactly the guarded fix proposed there, verified against main first (diagnosis was line-accurate: the
Nonearm tolerated the close, theStreamEndedarm fell throughclassify_eventsource_error's catch-all).saw_finish_reasontracked in the compat read loop;Some(Err(StreamEnded))with the flag set →break(same path as gracefulNone)tests/openai_compat_stream_test.rs(wiremock, MiniMax-shaped config): DONE-less close afterfinish_reason→ clean completion, accumulated content,StopReason::Stop; close before anyfinish_reason→ stillErrField report: yologdev/yoyo-evolve#612 (yoyo can then drop its cosmetic mitigation
1bb04f1eafter the next yoagent release).Test plan
--all-features; clippy-Dwarningsclean🤖 Generated with Claude Code