[Bug] Shared model retry helpers ignore numeric Retry-After headers
Description
The shared retry_sync() and retry_async() helpers use local exponential backoff but ignore numeric HTTP Retry-After headers exposed by provider SDK exceptions.
For rate-limited requests, this can retry before the provider's requested delay has elapsed, causing repeated 429 responses and unnecessary queue pressure.
Reproduction
Use a retryable provider exception whose response contains a numeric delay:
error = RuntimeError("429 TooManyRequests")
error.response = type("Response", (), {"headers": {"Retry-After": "43"}})()
Call retry_async() with base_delay=0.5, max_delay=8, jitter=False, and make the first attempt raise that exception. The helper currently sleeps for the local backoff instead of at least 43 seconds.
The same issue applies to retry_sync().
Expected behavior
For a valid numeric Retry-After value, wait for the larger of:
- the existing local exponential backoff; and
- the provider-requested delay.
Malformed, negative, or non-finite header values should be ignored without changing current retry classification.
The header may be available directly on the exception or on exception.response.headers, including through a wrapped exception chain.
Related work
#4417 included broader queue reliability changes and an implementation for Retry-After, but it was closed without merge. This issue isolates the missing shared retry-helper behavior on current main.
Taking this — will add numeric Retry-After honor in shared retry_sync/retry_async helpers with a regression test.
Fix PR: https://github.com/volcengine/OpenViking/pull/4796
Supporting real-environment evidence for this issue from the Compile path (OpenViking 0.5.1, Windows, uv tool install).
A full-corpus Compile task hit the embedding provider's RPS limit during Shuffle:
POST /api/v1/compile/embeddings: 220 × HTTP 200, 113 × HTTP 429.- Provider body:
{"error": {"code": 11202, "message": "requests per second limit exceeded", "type": "rate_limit_error"}}. openviking.models.embedder.retry_embedderretried 3 times with local fixed/exponential backoff, then the batch failed. In the logs we do not see any use of aRetry-Afterheader (this provider did not send one), but the retry helper behavior matches the issue: it only follows its local backoff schedule.- The failure then propagated through
bounded_jobsinto a task-levelCOMPILE_INCOMPLETE, so a single rate-limit window ended a 10.5-hour task.
The compile-specific complication is that /api/v1/compile/embeddings accepts up to 32 texts and internally runs groups of 4 against the embedder, while the client-side shuffle_concurrency only limits jobs, not upstream request rate. A shared helper that honors Retry-After and applies a global retry/pacing budget would directly help this path; today callers must implement their own pacing outside OpenViking (we ended up pacing one 32-text request every 8–12 seconds in a recovery driver).
For reference, the upstream failure chain observed:
RetryEmbedder.embed_async (3 attempts exhausted) → /api/v1/compile/embeddings 429 → OpenVikingError → Shuffle.vectors bounded_jobs (no failures sink) → pipeline_io aggregated ValueError("113 pipeline jobs failed: ...") → COMPILE_INCOMPLETE.
Data point for this issue from the VLM path, and one case where honoring Retry-After alone (#4796) would not have helped.
Version: OpenViking v0.5.3 (178a8cdfb), with bot/vikingbot/compile from main 4b92b3065. LiteLLM 1.102.4 (the current pin). The model was an OpenAI Responses model with a 4,000,000 TPM and 10,000 RPM limit.
What happened: we ran six directory compiles in parallel (knowledge-graph Skill, 128 workers each). That produced 302 rate-limit (429) errors. With the default vlm.max_retries of 3, jobs ran out of retries and failed, and five of the six compiles failed as a result.
Why the retries ran out: RetryVLM calls retry_sync / retry_async (openviking/utils/model_retry.py) with the defaults base_delay=0.5 and max_delay=8.0, and _compute_delay is min(0.5 * 2**attempt, 8) plus up to 0.5 s of jitter.
max_retries |
Total backoff before the job fails |
|---|---|
| 3 (default) | 3.5 to 5 s |
| 8 | about 40 to 44 s |
A per-minute token limit resets on a 60-second window. With the default, every retry lands in the same window that rejected the request.
Why Retry-After is not enough here: one 429 we captured from this workload reported 3,991,027 of 4,000,000 TPM used, 12,038 tokens requested, and a suggested retry of 45 ms. A hint that short only helps a single caller. With hundreds of concurrent workers it makes them all retry at once, so #4796's max(local backoff, Retry-After) still gives about 4 seconds in total.
Our workaround: vlm.max_retries: 8 and less parallelism (four compiles at 64 workers each instead of six at 128). That kept the runs within limits for us, but it is tuning for one workload rather than a general fix.
Ask: when a failure is classified as ModelErrorKind.RATE_LIMIT_ERROR, use a rate-limit schedule in the shared helpers rather than the generic 0.5 to 8 s one. model_retry.py already has one: rate_limit_retry_delay() (5 s base, 120 s cap, ±20% jitter). In v0.5.3, outside tests, only the tau2 benchmark uses it. Applying it in _compute_delay (or in #4796's _retry_delay_for_error) for rate-limit errors would make the default max_retries of 3 last longer than one TPM window, without tuning for each workload. Separately exposing base_delay / max_delay under vlm would also work.