feat: rate limit escalation circuit breaker - #46
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRate-limit handling now uses structured errors, deadline-clamped retries, explicit escalation variants, and fallback circuit-breaker routing. Stream event processing was refactored into helpers, with tests covering retry decisions, timeout behavior, error mapping, and fallback activation. ChangesRate-limit escalation
Sequence Diagram(s)sequenceDiagram
participant ApiClient
participant StreamHandler
participant BareLoop
participant FallbackManager
ApiClient-->>StreamHandler: rate-limited stream outcome
StreamHandler->>StreamHandler: retry with bounded backoff
StreamHandler-->>BareLoop: RateLimitEscalation
BareLoop->>FallbackManager: record_model_failure()
FallbackManager-->>BareLoop: fallback mode
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/stream/handler.rs`:
- Around line 1411-1418: Update the event polling logic around `event_deadline`
and the `tokio::select!` in the stream handler to compute the earliest
applicable deadline: use `initial_event_timeout` when `events_processed == 0`,
otherwise `per_event_timeout`, and cap it by the overall `total_stream_timeout`
deadline. Add the total-deadline branch to `tokio::select!` and return the
appropriate timeout error when either deadline expires.
- Around line 1206-1229: Rate-limit retries currently consume the outer generic
retry budget, causing escalation thresholds to be reached too early. Update the
stream retry loop around rate_limit_retry and the outer attempt handling to
track transport retries separately, allowing RateLimitConfig and
fallback_after_retries to govern rate-limit attempts independently while
preserving existing transport retry limits.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e4d6142d-a9dc-476f-9b9d-4f3259706021
📒 Files selected for processing (6)
CHANGELOG.mdsrc/api/error.rssrc/engine/bare.rssrc/engine/bare/stream.rssrc/error.rssrc/stream/handler.rs
feat: rate limit escalation circuit breaker
No description provided.