Skip to content

fix(llm): honor OpenAI's x-ratelimit-reset-* headers on 429s - #3508

Open
romanbsd wants to merge 1 commit into
vectorize-io:mainfrom
romanbsd:fix/openai-rate-limit-reset-headers
Open

fix(llm): honor OpenAI's x-ratelimit-reset-* headers on 429s#3508
romanbsd wants to merge 1 commit into
vectorize-io:mainfrom
romanbsd:fix/openai-rate-limit-reset-headers

Conversation

@romanbsd

Copy link
Copy Markdown

Summary

  • _rate_limit_retry_at only parsed the Retry-After header and the free-text error body, so a 429 without Retry-After (e.g. OpenAI's daily RPD cap) fell back to blind exponential backoff instead of the wait OpenAI actually specified.
  • Parse OpenAI's x-ratelimit-reset-requests / x-ratelimit-reset-tokens headers (Go duration format, e.g. "6m0s") and wait for whichever budget clears later. Requests/tokens can reset at different times.
  • Existing Retry-After and free-text body parsing paths are unchanged.

Test plan

  • uv run pytest tests/test_openai_compatible_response_hardening.py -q (11 passed)
  • uv run ruff check / uv run ruff format --check / uv run ty check on the changed file
  • Verified the patch applies cleanly and tests pass against the v0.9.1 tag

🤖 Generated with Claude Code

https://claude.ai/code/session_0184wdx18AyKn3amtvcqYRkU

_rate_limit_retry_at only parsed the Retry-After header and the
free-text error body, so a 429 without Retry-After fell back to blind
exponential backoff instead of the wait OpenAI actually specified.
Parse the x-ratelimit-reset-requests/-tokens headers (Go duration
format, e.g. "6m0s") and wait for whichever budget clears later.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0184wdx18AyKn3amtvcqYRkU
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