Skip to content

feat(sse): per-egress pacing + fleet-wide backoff for opencode rotation (opt-in) - #14290

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
maxmad64bis:feat/egress-throttle-fleet-backoff
Sep 21, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
maxmad64bis:feat/egress-throttle-fleet-backoff

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #13924. Only the last commit is this PR's; I'll rebase once it lands.

⚠️ base-red inherited: #13866

Summary

When several concurrent requests share the same network egress, multi-account rotation fires them all at once, so a burst of 429s hits the provider simultaneously. After ten burst 429s in a minute the fleet is treated as suspect for 60-120 s, during which each request tries at most two accounts before handing over to the wait-and-replay path of #13924 (heartbeat plus one capped leg; last upstream answer only when that path is off), and the first success clears the state. Real rate limits (parseable Retry-After or rate-limit wording) never feed the suspect counter and keep the existing early-stop path; everything fails open and the behavior is opt-in via OPENCODE_EGRESS_THROTTLE_ENABLED=1 (default off: rotation unchanged), pacing dispatches per egress for #10880 (IP-bucketed 429s waste one upstream call per sibling account) and backing the fleet off for #10920 (stop retrying sibling connections after an IP-scoped 429) instead of locking accounts after the fact.

Related Issues

Validation

  • Change type: provider
  • Focused tests and category gates from the golden path
  • npm run lint
  • Reconciled with the current active release base; focused checks rerun afterward
  • Production-code changes include a new or updated automated test in this PR

Tests Added Or Updated

  • tests/unit/opencode-egress-throttle.test.ts (new, 22 tests: config defaults and bounds, cap and FIFO, jitter ranges, fleet window and expiry, fail-open paths, first-success reset, simulated burst wave, per-arm leak guards, caps eviction)
  • tests/unit/opencode-429-park-resume.test.ts (handover case: a fleet-suspect slot budget runs the park-and-replay instead of returning the last 429)

Coverage Notes

  • open-sse/executors/opencodeEgressThrottle.ts (new, ~545 lines) is covered by the 22 tests above; open-sse/executors/opencode.ts seam (slot-budget arm plus handover) is covered by the handover test. No existing test needed changes.

Reviewer Notes

  • Default-off (OPENCODE_EGRESS_THROTTLE_ENABLED unset: rotation byte-identical); tuning via OPENCODE_EGRESS_THROTTLE_{CAP,WAIT_MIN_MS,WAIT_MAX_MS,WAIT_BUDGET_MS,FLEET_WINDOW_MS,FLEET_THRESHOLD,SUSPECT_MIN_MS,SUSPECT_MAX_MS,SUSPECT_SLOTS} with bounds, never throws. Alongside fix(sse): park request with heartbeat after repeated transient 429s, replay one capped leg #13924, the slot-budget arm hands over to its wait-and-replay instead of returning the last 429.
  • File-size rebaseline for open-sse/executors/opencode.ts (1233 to 1247: irreducible seam, handover arm; logic lives in the leaf modules under the cap).
  • api-typecheck shows 2 pre-existing errors (rerankProviderNodes.ts, antigravity.ts, both TS2677, files outside this PR, unchanged since merge-base) — inherited from the red base (🔴 Release branch not green: release/v3.8.51 #13866), not this PR.

…w#13924 rewrite

Merges origin/release/v3.8.51 (which already carries diegosouzapw#13924's
rewrite, squash-merged as 893fef9) into this PR branch. The three
conflicting paths (open-sse/executors/opencode.ts,
tests/unit/opencode-429-park-resume.test.ts,
config/quality/file-size-baseline.json) are resolved to base's
diegosouzapw#13924 semantics plus only diegosouzapw#14290's own egress-throttle additions
(opencodeEgressThrottle.ts + its dedicated test file, untouched).
Default-off (OPENCODE_EGRESS_THROTTLE_ENABLED unset): behavior is
byte-identical to the tip, proven by the existing "env-module off by
default: everything is a no-op" test plus the full opencode-*
suite (101/101 passing). With the flag on, the new fleet-suspect
slot-budget hands over to diegosouzapw#13924's park-and-replay path instead of
returning the last 429, proven by the added handover test.

Also fixes a rebaseline-note label carried over from the PR's own
commit (wrong PR number, stray non-English word) in
config/quality/file-size-baseline.json.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 3411317 into diegosouzapw:release/v3.8.51 Sep 21, 2026
7 of 16 checks passed
diegosouzapw added a commit that referenced this pull request Sep 21, 2026
Keep the drain's t06 Zod validation on /v1/responses/input_tokens
(ours) over the tip's empty passthrough schema. Bump the
server-owned-tool-loop flag-count snapshot 74 → 75 to match the
#14290 flag that landed on the tip.

Env-doc-sync is clean after the merge (0 code vars missing from
.env.example).
@maxmad64bis
maxmad64bis deleted the feat/egress-throttle-fleet-backoff branch September 23, 2026 00:22
diegosouzapw added a commit to aldoeliacim/OmniRoute that referenced this pull request Sep 24, 2026
…alog fix

Neither diegosouzapw#14290 (an unrelated merged PR) nor diegosouzapw#5460/diegosouzapw#5465 (unrelated closed
issues about Reka and t3.chat) documents this bug — no filed issue exists
for it. Drop the bogus links: rename the changelog fragment to the PR's
own number (14448, matching the repo's fragment-naming convention) and
drop the diegosouzapw#14290 link from its body, and remove the diegosouzapw#5460/diegosouzapw#5465 reference
from the code comment in modelRouteProjection.ts.

Also ran the two regression suites named in review
(tests/unit/noauth-catalog-only-providers.test.ts and
tests/unit/noauth-local-catalog-intentional.test.ts) in isolation to
confirm both pass; the earlier failure seen when run together was
SQLITE_BUSY DB contention from the shared devbox, not a real defect.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
diegosouzapw added a commit to aldoeliacim/OmniRoute that referenced this pull request Sep 24, 2026
The first commit only carried the file rename; this carries the actual
content change it described — drop the diegosouzapw#14290 link from the changelog
fragment body and the diegosouzapw#5460/diegosouzapw#5465 reference from the code comment.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
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