Skip to content

fix(sse): park request with heartbeat after repeated transient 429s, replay one capped leg - #13924

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:feat/n95-park-fanout
Sep 21, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:feat/n95-park-fanout

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ base-red inherited: #13866

Summary

Repeated transient 429s from the opencode rotation used to sweep every account in the fleet, burning cooldown budget for no gain. After 6 consecutive transient 429s (or a fresh local pool-strain signal), the request now waits with a heartbeat and then retries through at most 3 accounts in order instead of sweeping the whole fleet. Default behavior is unchanged: the wait-and-retry path runs only when OPENCODE_PARK_AND_RESUME is set.

Related Issues

Validation

  • Change type: provider
  • Focused tests and category gates from the golden path — focused suites only (new 7/7 plus neighbors 23/23 locally); full golden-path gates run in CI on this PR
  • 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-429-park-resume.test.ts (new, 7 cases: below-threshold rotation, threshold park with heartbeat and capped replay, fresh/stale/future strain signal, flag off, client abort mid-wait).
  • tests/unit/feature-flags-settings.test.ts (flag count 72 to 73), docs/reference/FEATURE_FLAGS.md (catalog row), .env.example + docs/reference/ENVIRONMENT.md (OPENCODE_PARK_AND_RESUME and OPENCODE_POOL_STRAIN_MARKER_PATH).
  • Neighbors rerun: tests/unit/opencode-transient-rotation.test.ts, tests/unit/opencode-rate-limited-classify.test.ts.

Coverage Notes

  • open-sse/executors/opencode.ts (+40-line call site) is covered by the new test through the dispatch path; the park/replay helper open-sse/executors/opencodeParkResume.ts is covered by all 7 new cases.
  • File-size rebaseline for open-sse/executors/opencode.ts (1185 to 1226, irreducible call site; logic lives in the new 258-line module under the cap).

Reviewer Notes

  • Flag OPENCODE_PARK_AND_RESUME defaults to off (fail-closed); with the flag off every 429 rotates exactly as before.
  • Streaming: the retried response is relayed as received (no re-normalization of the prefix); the wait holds server resources up to 2 minutes (long-stream gates apply).
  • CI reds are inherited from the red base (🔴 Release branch not green: release/v3.8.51 #13866), not from this diff: the third-party PR fix(sse): treat antigravity empty completions with a normal stop as valid 200s (#14160) #14243 on the same base release/v3.8.51 fails the same 9 jobs (API Route Typecheck, Docs Gates, Fast Quality Gates, Merge integrity, ESLint, Unit fast-path 1-4/4); every file cited by the failing gates is outside this diff. Non-blocking for this PR.

@maxmad64bis
maxmad64bis force-pushed the feat/n95-park-fanout branch 3 times, most recently from d7c5ffb to 7b84ef5 Compare September 16, 2026 21:15
@maxmad64bis
maxmad64bis marked this pull request as ready for review September 16, 2026 21:16
@maxmad64bis
maxmad64bis force-pushed the feat/n95-park-fanout branch 2 times, most recently from 3cfb3c7 to 847cff7 Compare September 16, 2026 22:20
@diegosouzapw
diegosouzapw merged commit 893fef9 into diegosouzapw:release/v3.8.51 Sep 21, 2026
7 of 16 checks passed
diegosouzapw added a commit to maxmad64bis/OmniRoute that referenced this pull request Sep 21, 2026
…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 added a commit that referenced this pull request Sep 21, 2026
…on, opt-in (#14290)

Per-egress pacing and fleet-wide suspect backoff for OpenCode free-tier rotation,
layered on #13924's park-and-replay: paces requests per egress identity, marks an
egress fleet-suspect after repeated transient 429s, and hands a suspect slot
budget over to the park/heartbeat path instead of surfacing the last 429.
Opt-in via OPENCODE_EGRESS_THROTTLE_ENABLED (default off) — with the flag off every
hook is a no-op and behavior is identical to the tip.

Stacked on #13924 (merged as 893fef9); reconciled onto the merged form.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@maxmad64bis
maxmad64bis deleted the feat/n95-park-fanout branch September 23, 2026 00:22
diegosouzapw added a commit that referenced this pull request Sep 24, 2026
…nked markers (#14487)

The external pool watcher (#13924) writes /tmp/opencode-pool-strain.json;
moving the default under DATA_DIR would silently stop reading it. Keep the
default and make the shared path safe instead: lstat (never follow a
planted symlink), require a regular file owned by the process uid with no
group/other write bit, bounded read. ENVIRONMENT.md reverted to the /tmp
default so it stays in sync with .env.example and the i18n mirrors.
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