Repository navigation
Judge a stream's speed on what it generates visibly - #133
Merged
Merged
Conversation
Fixes to how a stream's speed is judged against its provider's minimum: - Counts the upstream reports are no longer used. Gemini's running output count includes the thoughts it does not show; once it leaped ahead of the text, the text counted for nothing and a fast stream could be cut. - Summarised reasoning is left out: Responses reasoning summaries, Anthropic thinking blocks, Gemini thought parts and Bedrock reasoning content arrive in bursts while the model reasons at full speed. No second is judged while such a phase is open, and its time and text are left out of the window after. Reasoning streamed as generated (Chat reasoning_content, Responses reasoning_text) still counts. - A long pause is a quarter of the window, at most 5 s, and no second is judged whose last content is more than a second old: the burst an upstream sends after holding tokens back is waited for. - The answer's end is also seen by the format's last frame (Anthropic message_stop, Chat [DONE], Responses response.completed), not only by a stop reason. - The upstream's connection is dropped at the cut, before the error frame goes to the client. - The affinity is dropped and the speed written to the log row only when the stream's outcome is the cut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 to how a stream's speed is judged against its provider's minimum (follow-up to #131).
reasoning_content, Responsesresponse.reasoning_text.delta) still counts.message_stop, Chat[DONE], Responsesresponse.completed), not only from a stop reason. Gemini and Bedrock end with their stop reason.Tests
New unit tests in
proxy::min_speed. Run against the previous implementation, these fail:reasoning_streamed_as_generated_is_judgedguards that raw reasoning still counts.Also run:
make precommitandpnpm lintpass.gateway_min_speed,gateway_retryandstreaming_and_cacheintegration tests pass locally, except onestreaming_and_cachetest that needs ClickHouse, which was not running; CI runs it.The connection drop and the outcome guard come without a failing test: the pump returns right after the cut, so locally there is no ordering that tells the old code from the new.
🤖 Generated with Claude Code