fix: handle rate_limit_event crash in chat sessions#211
Merged
leonvanzyl merged 4 commits intomasterfrom Feb 23, 2026
Merged
Conversation
…views - Create VISION.md establishing AutoForge as a Claude Agent SDK wrapper exclusively, rejecting integrations with other AI SDKs/CLIs/platforms - Update review-pr.md step 6 to make vision deviation a merge blocker (previously informational only) and auto-reject PRs modifying VISION.md - Add .claude/launch.json with backend (uvicorn) and frontend (Vite) dev server configurations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Claude CLI sends `rate_limit_event` messages that the SDK's `parse_message()` doesn't recognize, raising `MessageParseError` and crashing all three chat session types (spec, assistant, expand). Changes: - Bump claude-agent-sdk minimum from 0.1.0 to 0.1.39 - Add `check_rate_limit_error()` helper in chat_constants.py that detects rate limits from both MessageParseError data payloads and error message text patterns - Wrap `receive_response()` loops in all three `_query_claude()` methods with retry-on-rate-limit logic (up to 3 retries with backoff) - Gracefully log and skip non-rate-limit MessageParseError instead of crashing the session - Add `rate_limited` message type to frontend TypeScript types and handle it in useSpecChat, useAssistantChat, useExpandChat hooks to show "Rate limited. Retrying in Xs..." system messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
0.1.0to0.1.39for better message type support_query_claude()methods (spec, assistant, expand) — up to 3 retries with exponential backoffMessageParseErroris logged as a warning instead of crashing the sessionrate_limitedfrontend message type with UI handling in all three chat hooks, showing "Rate limited. Retrying in Xs..." system messagesContext
The Claude CLI sends
rate_limit_eventmessages that the SDK'sparse_message()doesn't recognize, raisingMessageParseErrorwhich propagates unhandled through_query_claude()and crashes the entire session.Test plan
ruff check .— all checks passedpython test_security.py— 169 passed, 0 failedpython -m pytest test_rate_limit_utils.py— 22 passedcd ui && npm run lint— 0 errorscd ui && npm run build— TypeScript compiles and Vite builds successfully🤖 Generated with Claude Code