Skip to content

fix(executors): parse retryAfter timestamp for precise backoff on 429 - #879

Open
anuragg-saxenaa wants to merge 1 commit into
decolua:masterfrom
anuragg-saxenaa:fix/minimax-retryafter-precise-backoff
Open

anuragg-saxenaa wants to merge 1 commit into
decolua:masterfrom
anuragg-saxenaa:fix/minimax-retryafter-precise-backoff

Conversation

@anuragg-saxenaa

Copy link
Copy Markdown
Contributor

Summary

  • Override parseError() in DefaultExecutor and OpenCodeGoExecutor to extract retryAfter ISO timestamp from MiniMax (and similar providers) 429 responses
  • Returns precise resetsAtMs instead of falling back to exponential backoff guessing
  • Handles both retryAfter (ISO string) and retry_after_ms / retryAfterMs (numeric ms)

Test plan

  • Send a 429 from MiniMax with retryAfter field → verify resetsAtMs is set to the parsed timestamp
  • Send a 429 without retryAfter → verify falls through to default exponential backoff
  • Verify both executors (default.js + opencode-go.js) behave identically

Closes #878

When providers (e.g. MiniMax) return 429 with a retryAfter ISO timestamp,
the base parseError() ignores it and falls back to exponential backoff
(starting at 2s, doubling). This adds a parseError() override in both
default.js and opencode-go.js that extracts the precise retryAfter
timestamp and returns resetsAtMs — so the caller waits exactly until the
provider's reset window, not a guessed backoff.

Co-Authored-By: Claude <noreply@anthropic.com>
@anuragg-saxenaa

Copy link
Copy Markdown
Contributor Author

👋 Gentle follow-up — this PR has been ready for ~35 days and CI is green. Happy to address any feedback or close if no longer relevant. Let me know how to move it forward.

diegosouzapw added a commit to diegosouzapw/OmniRoute that referenced this pull request Jul 3, 2026
The per-account cooldown path (getUpstreamRetryHintMs -> parseRetryFromErrorText
in open-sse/services/accountFallback.ts) only recognized retry hints from the
HTTP Retry-After header or free-text prose in the response body. Some
providers instead surface the hint as structured fields on the 429 JSON
body itself (e.g. {"error":{"retryAfter":"<ISO>"}} or
{"retry_after_ms":45000}), which were previously ignored, causing the
connection to fall back to the generic exponential-backoff cooldown instead
of the provider's own reset window.

parseRetryFromErrorText now attempts a JSON.parse of the error text first
and reads retryAfter (bare ISO 8601, converted to a future duration) or
retry_after_ms / retryAfterMs (already in milliseconds) from either the
top level or a nested `error` object, reusing the existing
MAX_PROVIDER_COOLDOWN_MS 30-day cap. No new regexes were added.

Co-authored-by: Anurag Saxena <anuragg.saxenaa@gmail.com>
Inspired-by: decolua/9router#879
afandiaziz pushed a commit to afandiaziz/9router that referenced this pull request Aug 9, 2026
29 PR upstream di-cherry-pick (semua masih open upstream per 2026-08-09).
Rincian lengkap + link per PR ada di FORK-CHANGES.md.

P1 skala 2475 koneksi : decolua#2798 decolua#410 decolua#2879 decolua#879 decolua#2997
P2 akurasi token/usage: decolua#2422 decolua#2658 decolua#2762 decolua#2453 decolua#2668 decolua#2361
P3 provider & combo   : decolua#2526 decolua#3125 decolua#1434 decolua#2689 decolua#2439 decolua#2724 decolua#2647 decolua#1805
                        decolua#2909 decolua#2853 decolua#2508 decolua#2928 decolua#2345 decolua#2112 decolua#2786
P4 keamanan           : decolua#1666 decolua#2776

Revert decolua#664: menambah transformRequest kedua di DefaultExecutor sehingga
menimpa yang pertama dan mematikan stream_options/text.format/
injectReasoningContent/stripUnsupportedParams — termasuk PR decolua#3081 yang
sudah dipakai produksi.

Test: 88 gagal / 1783 lulus — nol regresi vs baseline v0.5.50 (88/1656).
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.

fix(executors): parse retryAfter timestamp for precise backoff on 429

1 participant