Repository navigation
fix(sse): set X-OmniRoute-Selected-Connection-Id on successful combo dispatches (#11810) - #11986
Merged
diegosouzapw merged 1 commit intoAug 29, 2026
Conversation
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…dispatches (diegosouzapw#11810) (diegosouzapw#11986) Co-authored-by: Markus Hartung <mail@hartmark.se>
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.
Closes #11810
Root cause
On a successful provider dispatch,
handleSingleModelChat()'sresult.successbranch insrc/sse/handlers/chat.tsreturnedresult.response(non-streaming) orwrapResponseWithOAuthSessionRelease(result.response, releaseOAuthSession)(streaming) directly, without first callingwithSelectedConnectionHeader()— unlike every failure exit in the same function, which does call it. As a result,X-OmniRoute-Selected-Connection-Idwas absent on every successful response for a dynamically-selected (unpinned) connection, socombo.ts's consumers (success-decay, provider cooldown recovery, webhook attribution, session stickiness, LKGP) fell back to the target's staticconnectionId, which is empty for provider-level combo targets likeopenai/o3-mini.Fix
Apply
withSelectedConnectionHeader(result.response, credentials?.connectionId)toresult.responsebefore both the streaming-wrap and the direct non-streaming return in theresult.successblock ofhandleSingleModelChat, mirroring the pattern already used on every failure exit of the same function.Regression test
tests/unit/combo-success-selected-connection-header-11810.test.ts— two cases (non-streaming and streaming success) that dispatch through the realhandleChat→handleComboChat→handleSingleModelChatpipeline with a mocked upstreamfetch, and assert the response carriesX-OmniRoute-Selected-Connection-Idfor a dynamically-selected (unpinned provider-level) connection.expected the response to carry the dynamically selected connection id (...), got nulltests 2, pass 2, fail 0Gates run (all green)
node --import tsx/esm --test tests/unit/combo-success-selected-connection-header-11810.test.ts— 2/2 passtests/unit/combo-selected-connection-success.test.ts,tests/unit/rate-limit-local-error-classification.test.ts,tests/unit/rate-limit-queue-timeout-lockout.test.ts,tests/unit/account-fallback-service.test.ts,tests/unit/stream-early-eof-affinity-8928.test.ts,tests/unit/chat-safetynet-reqid-6097.test.ts— 101/101 passnode scripts/check/check-file-size.mjs— OKnode scripts/check/check-complexity.mjs— OK (2672 violations vs baseline 2774)node scripts/check/check-cognitive-complexity.mjs— OK (1192 violations vs baseline 1223)node scripts/check/check-changelog-integrity.mjs— OKnpm run typecheck:core— cleannpx eslint --suppressions-location config/quality/eslint-suppressions.json src/sse/handlers/chat.ts tests/unit/combo-success-selected-connection-header-11810.test.ts— 0 errorsNote:
tests/unit/combo-provider-cooldown.test.ts("combo failover skips the cooled provider target on the next request") was observed flaking under this run due to extreme devbox CPU contention from many concurrent parallel sessions (test durations of 100-124s for a test whose logic depends on a 3s cooldown window expiring between two sequential requests). This test is structurally unrelated to this fix (it asserts connection-cooldown/retry-count behavior, not response headers), and the diff here only touches theresult.successreturn path — no cooldown/backoff logic. Re-running the other 101 sibling tests touching the same header/function all passed.