Skip to content

fix(provider): honour Retry-After above the backoff cap and retry 529 (RR5) - #118

Merged
lg2m merged 1 commit into
mainfrom
fix/rr5-retry-after
Sep 22, 2026
Merged

lg2m merged 1 commit into
mainfrom
fix/rr5-retry-after

Conversation

@lg2m

@lg2m lg2m commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

RR5 of docs/plans/run-reliability.md; audit finding R01 (provider half). Based on main.

Behaviour

Two gaps in the pre-stream retry policy ended real runs that a short wait would have saved:

  • Anthropic answers overloaded_error with HTTP 529, which is not one of http's named statuses and was never in is_retryable_status: five audited runs "gave up after 8 attempts" on it.
  • A Retry-After above max_delay was clamped to 8 s, so the retry went out before the server said it would accept one and earned the same rejection again.

Now:

  • 529 is retryable.
  • Retry-After is a floor: parsed in delta-seconds and HTTP-date form (httpdate, already in Cargo.lock via hyper — zero transitive additions), never jittered down, slept in full above the exponential cap up to 60 s (RETRY_AFTER_CAP).
  • The ledger charges a server-directed wait at the exponential rate, so honouring the server cannot by itself exhaust the 30 s budget that bounds QQ's own guessing.
  • Compatible with fix(provider): retry attempts that outlive the backoff budget #114, which stopped charging attempt wall time to the budget.

Verification

  • retry_after_parses_delta_seconds_and_http_dates (future → 90 s, past → 0), overloaded_529_is_retryable, delay_before_retry_honors_retry_after_above_max_delay_up_to_the_cap, ledger_charges_a_server_directed_wait_at_the_exponential_rate; the exchange_honors_retry_after_before_success fixture no longer relies on max_delay clamping.
  • cargo test -p qq-provider (215) and the minimal profile --no-default-features --features test-support (168 + 17) green; workspace clippy -D warnings and fmt clean; qq-core 688 green.

Docs

providers.md § retry owner updated; ledger entry; RR1–RR3 marked shipped.

… (RR5)

Two gaps in the pre-stream retry policy ended real runs that a short wait
would have saved. Anthropic answers overloaded_error with HTTP 529, which
is not one of http's named statuses and so was never in
is_retryable_status: five audited runs "gave up after 8 attempts" on it.
And a Retry-After above max_delay was clamped to 8 s, so the retry went
out before the server said it would accept one and earned the same
rejection again.

529 is retryable. Retry-After is a floor: parsed in delta-seconds and
HTTP-date form (httpdate, already in the lock through hyper), never
jittered down, and slept in full above the exponential cap up to 60 s. The
ledger charges a server-directed wait at the exponential rate, so honouring
the server cannot by itself exhaust the 30 s budget that bounds QQ's own
guessing. Compatible with #114, which stopped charging attempt wall time.

Tests: HTTP-date past and future, 529, the 60 s cap, ledger charging; the
Retry-After exchange test no longer relies on max_delay clamping. Both
provider profiles green.
@lg2m
lg2m added this pull request to stack #121 September 22, 2026 04:21
@lg2m
lg2m merged commit 214b4cd into main Sep 22, 2026
4 checks passed
@lg2m
lg2m deleted the fix/rr5-retry-after branch September 22, 2026 05:28
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.

1 participant