pub fn retry_delay_from_headers(
headers: &HeaderMap,
attempt: u32,
) -> (Duration, bool)Expand description
Compute how long to wait before the next retry, consulting response headers.
Priority order:
retry-after(integer seconds, or an HTTP-date — integer is what Anthropic sends in practice, HTTP-date is handled as a best-effort fallback).anthropic-ratelimit-tokens-reset/anthropic-ratelimit-requests-reset(RFC 3339 UTC timestamp) — take the minimum of whichever is present.- Classic exponential back-off:
1s * 2^(attempt-1)(1 s, 2 s, 4 s …).
The returned duration is capped at RETRY_DELAY_CAP so a far-future
reset timestamp never hangs the turn forever. attempt is 1-based (first
retry = 1).
Returns (delay, from_header) — the bool is true when a header was
used (callers can emit a more informative notice message).