Repository navigation
fix(sse): accept first-party Claude empty end_turn in combo quality gate - #15598
Merged
diegosouzapw merged 2 commits intoOct 6, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
A complete Claude SSE lifecycle with zero content blocks and stop_reason end_turn/stop_sequence is a legitimate empty answer from Anthropic, but the combo quality gate treated it as an empty stream and failed over, replaying the request on other targets. The exemption is granted only when the connection that actually served the response is a first-party Anthropic/Claude connection: the selected connection (X-OmniRoute-Selected-Connection-Id, or the planned connection for a known provider) must exist, belong to claude/anthropic and use the official api.anthropic.com host. Unresolved aliases require the selected header. Anything uncertain fails closed. content_filter, incomplete lifecycles, empty opened text blocks and zero-byte bodies still fail over. Refs cheaper-inference#15586
diegosouzapw
merged commit Oct 6, 2026
09a1624
into
cheaper-inference:release/v3.8.52
43 of 51 checks passed
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.
Problem
A complete Claude SSE response can legitimately end without any content blocks:
message_start→message_deltawithstop_reason: end_turnorstop_sequence→message_stop. Combo quality validation currently treats every zero-content Claude lifecycle as an invalid empty response and triggers failover. For an official Anthropic response, this sends an otherwise valid empty turn to other targets.The exception must not be keyed by provider ID alone. An
anthropicorclaudeconnection can point to a custom, Claude-compatible base URL, and an unprefixed pinned alias can parse without a provider.Change
Introduce
isTrustedEmptyTurn(), a fail-closed check of the connection that actually served the response:X-OmniRoute-Selected-Connection-Id, which is set server-side for the served connection;claude/anthropictarget only, fall back to its planned connection ID if the header is missing;claudeoranthropic, to match a known request provider, and to use the officialapi.anthropic.comhost; missing, malformed, or unverifiable records are rejected.validateResponseQuality()accepts an empty turn only if that trust check passes,message_stopis present, nocontent_block_*event was opened, andstop_reasonisend_turnorstop_sequence. Validated responses retain byte-for-byte SSE replay.content_filter, incomplete lifecycles, empty opened text blocks, zero-byte bodies, third-party gateways, and unknown connections continue to fail over.The trust result is wired through priority, round-robin, runtime-unit, and pinned-model paths. Regressions cover selected and fallback connection IDs, custom hosts, provider mismatches, aliases, and the preserved failure cases.
Fixes #15586