Skip to content

fix(sse): persisted connection cooldown wins over transient rate-limit signal - #14708

Merged
diegosouzapw merged 5 commits into
cheaper-inference:release/v3.8.51from
maxmad64bis:fix/transient-persisted-precedence
Sep 25, 2026
Merged

diegosouzapw merged 5 commits into
cheaper-inference:release/v3.8.51from
maxmad64bis:fix/transient-persisted-precedence

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ base-red inherited: #14547

Summary

A persisted per-connection cooldown (rateLimitedUntil in the future) was bypassed whenever an in-memory transient rate-limit signal was set for the same provider: the connection was served again instead of being skipped. The persisted cooldown is now evaluated first on every dispatch path, so a connection under a future cooldown is always skipped.

Related Issues

No linked issue — standalone fix verified against the current tree.

Validation

  • Change type: routing
  • Focused tests and category gates from the golden path
  • npm run lint — ESLint on the touched files is clean
  • Reconciled with the current active release base; focused checks rerun afterward — reconciled with upstream/release/v3.8.51 at 7d23bcf8ec, rev-list HEAD..base = 0; file-size/complexity/eslint/unit rerun on the merged tree
  • Production-code changes include a new or updated automated test in this PR

Tests Added Or Updated

  • tests/unit/combo-transient-persisted-precedence.test.ts — persisted-first ordering at the shared predicate, gate, and round-robin pre-check, frozen clock, boundary at now, plus counter-cases keeping the legitimate transient bypass.
  • tests/unit/repro-combo-persisted-cooldown-preskip.test.ts — two assertions updated from the old transient-wins behavior to persisted-first.

Coverage Notes

Covered by the tests above; no coverage gate moved down on the touched files.

Reviewer Notes

Maintainer rework (merge-batch 2026-09-24)

  • Merged release/v3.8.51 into the branch (real merge, your commits kept). The only conflict was config/quality/file-size-baseline.json: kept both sides' annotations, took the tip's virtualFactory.ts ceiling (1258) and kept this PR's roundRobinCombo.ts ceiling (1285, re-measured on the merged tree).
  • Confirmed the getCachedProviderConnectionById import that the new round-robin pre-check needs is still present after the merge.
  • Red→green verified: with the three production files reverted to the release tip, 6 cases fail across combo-transient-persisted-precedence.test.ts and repro-combo-persisted-cooldown-preskip.test.ts; with this PR all 21 pass.
  • Gates on the merged tree: typecheck:core clean, check:open-sse-typecheck 0 errors, eslint clean on the touched files, check-file-size OK.

@maxmad64bis
maxmad64bis force-pushed the fix/transient-persisted-precedence branch from 34fb317 to 67aae29 Compare September 23, 2026 22:38
@maxmad64bis
maxmad64bis marked this pull request as ready for review September 23, 2026 22:49
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Solid, well-scoped fix — the persisted cooldown genuinely should win over the transient
in-memory rate-limit signal (matches AGENTS.md's own connection-cooldown precedence), and all
three call sites (the two predicate helpers plus the round-robin dispatch point) get the same
ordering. Test coverage looks real (imports the production predicates, not a reimplementation).
One heads-up for whoever merges: this file overlaps with #14585 (different functions, no text
conflict) but #14585 removes the getCachedProviderConnectionById import that this PR's new
round-robin call site depends on — if #14585 lands first, re-add that import here.

diegosouzapw and others added 2 commits September 24, 2026 02:04
Keep both file-size rebaselines (14708 persisted-cooldown + applied-proxy),
co-located freetier predicate changes merged cleanly.
@maxmad64bis

Copy link
Copy Markdown
Contributor Author

Rebased onto the current base: kept both file-size rebaselines (this PR plus the applied-proxy one) and the co-located freetier changes merged cleanly. Pre-check, tests (21), and lint re-verified on the merged tree.

@diegosouzapw
diegosouzapw merged commit 638d898 into cheaper-inference:release/v3.8.51 Sep 25, 2026
11 of 16 checks passed
fouadSalkini added a commit to fouadSalkini/OmniRoute that referenced this pull request Sep 26, 2026
…act guard

The guard now checks that resolveTargetTokenLimit lives only in
targetTokenLimit.ts and that roundRobinCombo.ts imports it. The readCache
import that the final cheaper-inference#14585 roundRobinCombo.ts carries serves the later
cheaper-inference#14708 cooldown check, which this base does not have, so it is not ported.
alvinveroy pushed a commit to alvinveroy/OmniRoute that referenced this pull request Sep 28, 2026
- Latest from origin/release/v3.8.51: a58000c fix(security): pre-request hooks
  in isolated realm (GHSA-9p9m-h9rj-rhhg) cheaper-inference#14916
- Routing bug of interest: 96f6aee fix(routing): keep request-scoped SSE
  errors out of cooldowns cheaper-inference#14585 — Codex SSE errors/refusals no longer poison
  account cooldowns or affect other accounts
- 07d2a8d fix(routing): serve sync tier from stored pricing snapshot cheaper-inference#14706
- 638d898 fix(sse): persisted connection cooldown wins over transient
  rate-limit signal cheaper-inference#14708
- 9c96184 fix(combo): skip connection cooldown on request-level parameter
  validation 400 cheaper-inference#14438

Resolved conflict on src/app/(dashboard)/dashboard/combos/page.tsx by taking
upstream's import (resolveProviderAlias from providerAlias.ts), which matches
upstream's downstream usage at the calling site.
@maxmad64bis
maxmad64bis deleted the fix/transient-persisted-precedence branch September 30, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants