Skip to content

feat: add rate limiting error handling - #44

Merged
bobrykov merged 2 commits into
masterfrom
feat/rate-limit
Jul 7, 2026
Merged

feat: add rate limiting error handling#44
bobrykov merged 2 commits into
masterfrom
feat/rate-limit

Conversation

@bobrykov

@bobrykov bobrykov commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 280ae564-2b30-4274-8ae3-bb1ab4bfea5d

📥 Commits

Reviewing files that changed from the base of the PR and between 5d39fe0 and cae63bb.

📒 Files selected for processing (1)
  • src/stream/handler.rs

📝 Walkthrough

Walkthrough

This 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)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding rate limiting error handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rate-limit

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fae53fa and 5d39fe0.

📒 Files selected for processing (5)
  • Cargo.toml
  • src/api/error.rs
  • src/engine/bare/stream.rs
  • src/stream.rs
  • src/stream/handler.rs

Comment thread src/stream/handler.rs
Comment thread src/stream/handler.rs
@bobrykov
bobrykov merged commit 1c109db into master Jul 7, 2026
7 checks passed
@bobrykov
bobrykov deleted the feat/rate-limit branch August 4, 2026 05:23
bobrykov added a commit that referenced this pull request Aug 18, 2026
feat: add rate limiting error handling
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