feat: add rate limiting error handling - #44
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 (1)
📝 WalkthroughWalkthroughThis PR adds structured rate-limit handling across the API error and stream layers, including retry-after parsing, mid-stream detection, and rate-limit-aware retry backoff. It also adds an optional HTTP-date parser dependency, re-exports new stream types, and updates one dispatch comment. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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 2261-2265: The parse_retry_after_http_date test in the stream
handler is hitting the httpdate-only path, so it needs to be aligned with the
providers feature gate. Update the test near parse_retry_after to either add
#[cfg(feature = "providers")] or ensure the providers feature is enabled in the
relevant test configuration, so it only runs when the httpdate branch is
available.
- Around line 1205-1214: The retry loop in stream_turn is ignoring
StreamOutcome::RateLimited, so DetectedRateLimit::detect and the rate-limit
config fields are not affecting sleep behavior. Update the StreamHandler
retry/fallback path to inspect
StreamHandlerError::StreamFailed(StreamOutcome::RateLimited { .. }) and, when
present, use the rate-limit-specific delay logic from RateLimitConfig (including
backoff and respect_retry_after) instead of always calling
retry_config.base_delay(attempt). Ensure the handling is wired through the
existing retry loop and fallback decision points so 429/503 responses follow the
server-advised policy.
🪄 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: ee9b239a-d110-4c8e-8eed-57fc230989e7
📒 Files selected for processing (5)
Cargo.tomlsrc/api/error.rssrc/engine/bare/stream.rssrc/stream.rssrc/stream/handler.rs
feat: add rate limiting error handling
No description provided.