Skip to content

feat: improve rate limiting with conservative thresholds and exponent…#142

Merged
patrickfleith merged 1 commit intopatrickfleith:mainfrom
aidenerdogan:feat/improve-rate-limiting
Mar 5, 2026
Merged

feat: improve rate limiting with conservative thresholds and exponent…#142
patrickfleith merged 1 commit intopatrickfleith:mainfrom
aidenerdogan:feat/improve-rate-limiting

Conversation

@aidenerdogan
Copy link
Contributor

Changes

Rate Limiting Improvements

  • Conservative threshold: Wait at 90% of rpm_limit instead of 100%
  • Increased safety margin: 2s instead of 1s
  • Better logging: Shows current request count (X/Y format)
  • Cleanup after waiting: Removes stale timestamps

Exponential Backoff Retry

  • Auto-retry on RateLimitError: Up to 3 attempts
  • Exponential backoff: 5s → 10s → 20s between retries
  • Graceful degradation: Continues on success, fails after max retries

Error Handling

  • Exception detection: Checks if batch items are exceptions
  • Response validation: Validates that the choices attribute exists before access
  • Detailed error messages: Includes batch item index for debugging

Testing

Tested with Mistral API (rpm_limit: 7), generating 285 MCQs without rate limit errors.

Fixes rate-limiting issues when using strict API providers.

@patrickfleith patrickfleith merged commit e9c3c2f into patrickfleith:main Mar 5, 2026
1 check failed
@patrickfleith
Copy link
Owner

LGTM

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.

2 participants