Repository navigation
Conversation
…ons as errors Signed-off-by: Josh Cox <6137404+joshuacox@users.noreply.github.com>
Contributor
This branch has not been deployed
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.
What
In
decode_openai_chat_stream, afinish_reasonofabort,errororrepetitionnow decodes to a stream error carrying the messageprovider finished with finish_reason "<reason>"instead of a message stop. Each encoder already renders a stream error as its terminal error event: anerrorevent for Anthropic clients,{"type": "error"}for Responses clients, and an{"error": ...}chunk for Chat clients.Why
Related to #876. That issue covers non-streaming, and #884 fixes the buffered path with the same message and the same three reasons. The streamed path has the same hole: the Chat stream decoder passes the finish reason through as a stop, so a generation that did not complete reaches Anthropic clients as
end_turnand Responses clients asresponse.completed.This started as an addendum PR into the branch behind #884. Colin suggested targeting
maindirectly instead, so it is a standalone PR here and the addendum is closed.Tests
failed_finish_reasons_stream_as_errorsinstream_translation.rs: for each of the three reasons, Anthropic clients get an error event and nomessage_delta, and Responses clients get an error event and noresponse.completed. It fails on unmodifiedmainand passes with the change.cargo test --workspace: 961 passed, 0 failedcargo clippy --workspace --all-targets -- -D warnings: cleancargo fmt --all --check: cleanSummary by CodeRabbit