Repository navigation
fix(service): Do not record a model stream that fails after HTTP 200 - #71
Open
sentry-junior[bot] wants to merge 1 commit into
Open
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
A provider or gateway can send HTTP 200 and then end the stream with an error, such as a gateway timeout. The recorder skipped only 429 and 5xx responses, so it kept such a stream, and each later run replayed the failure. The recorder now treats a failed event stream like a 5xx: the client gets the stream, but no recording is written. A stream failed when it has an error event, a finish reason of `error`, or no end (an Anthropic Messages stream without `message_stop`, or an OpenAI Chat Completions stream without a finish reason). Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
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.
A provider or gateway can send HTTP 200 and then end the stream with an error. The recorder skipped only 429 and 5xx responses, so it stored such a stream, and every later run replayed the failure. getsentry/junior hit this: a Junior eval replayed a 200 stream that ended in
AI provider error: timeouton every run, including all of the client's retries.The recorder now treats a failed event stream like a 5xx. The client still gets the stream as it came, but no recording is written.
isFailedStream(streams.ts) reads the stream's own signals, not its error text. A stream failed when it has:event: error, atypeoferrororresponse.failed, or anerrorobject (OpenAI Chat Completions)error(finishReason,finish_reason, orstop_reason)message_startbut nomessage_stop, or an OpenAI Chat Completions stream with no finish reasonThese are the same checks that the Pi Anthropic client uses when it decides a stream failed (
event: error, or "stream ended before message_stop"). A stream that drops its connection mid-body was already safe:readBodyrejects, so nothing is recorded.Streams in other formats are recorded as before unless they have one of the error signals above. The stream in
deployed.test.tsgains themessage_stopthat a real Anthropic stream always sends.via @BYK.
--
View Session [Sentry]