Skip to content

fix(sdk): tune rate limiter for fail-fast behavior#265

Merged
AbirAbbas merged 1 commit intomainfrom
fix/openrouter-rate-limit-tuning
Mar 13, 2026
Merged

fix(sdk): tune rate limiter for fail-fast behavior#265
AbirAbbas merged 1 commit intomainfrom
fix/openrouter-rate-limit-tuning

Conversation

@AbirAbbas
Copy link
Contributor

Summary

  • Reduce rate limiter default aggressiveness to prevent 2+ hour workflow runtimes when using rate-limited providers (OpenRouter, etc.)
  • Previous defaults: 20 retries, 300s max delay, 300s circuit breaker timeout — caused cascading backoff that compounded across parallel agents
  • New defaults: 5 retries, 0.5s base delay, 30s max delay, circuit breaker threshold 5 with 30s timeout
  • Max theoretical wait per call drops from ~100 minutes to ~2.5 minutes

Changes

Parameter Before After
max_retries 20 5
base_delay 1.0s 0.5s
max_delay 300s 30s
circuit_breaker_threshold 10 5
circuit_breaker_timeout 300s 30s

Applied consistently across:

  • Python StatelessRateLimiter
  • TypeScript StatelessRateLimiter
  • Python AIConfig Field defaults

Test plan

  • Python rate limiter tests (10 tests pass)
  • TypeScript rate limiter tests (9 tests pass)
  • AIConfig tests (7 tests pass, 3 new functional tests added)
  • All existing tests pass with no regressions
  • Deploy and verify workflow runtime reduction on OpenRouter+MiniMax workloads

🤖 Generated with Claude Code

Reduce exponential backoff aggressiveness to prevent 2+ hour workflow
runtimes when using rate-limited providers like OpenRouter. The previous
defaults (20 retries, 300s max delay, 300s circuit breaker) caused
cascading backoff that compounded across parallel agents.

New defaults: 5 retries, 0.5s base delay, 30s max delay, circuit breaker
threshold 5 with 30s timeout. Max theoretical wait per call drops from
~100 minutes to ~2.5 minutes.

Changes:
- Python StatelessRateLimiter: max_retries 20→5, base_delay 1.0→0.5,
  max_delay 300→30, circuit_breaker_threshold 10→5, timeout 300→30
- TypeScript StatelessRateLimiter: identical parameter changes
- AIConfig: updated Field defaults to match rate limiter
- Added functional tests validating new defaults and max wait bounds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AbirAbbas AbirAbbas requested a review from a team as a code owner March 13, 2026 14:55
@github-actions
Copy link
Contributor

Performance

SDK Memory Δ Latency Δ Tests Status
Python 9.3 KB +4% 0.31 µs -11%
TS 353 B - 1.42 µs -29%

✓ No regressions detected

@AbirAbbas AbirAbbas enabled auto-merge March 13, 2026 15:11
@AbirAbbas AbirAbbas disabled auto-merge March 13, 2026 15:12
@AbirAbbas AbirAbbas merged commit 486ff3d into main Mar 13, 2026
30 checks passed
@AbirAbbas AbirAbbas deleted the fix/openrouter-rate-limit-tuning branch March 13, 2026 15:12
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