Skip to content

fix: handle rate_limit_event crash in chat sessions#211

Merged
leonvanzyl merged 4 commits intomasterfrom
fix/rate-limit-event-crash
Feb 23, 2026
Merged

fix: handle rate_limit_event crash in chat sessions#211
leonvanzyl merged 4 commits intomasterfrom
fix/rate-limit-event-crash

Conversation

@leonvanzyl
Copy link
Collaborator

Summary

  • Bump claude-agent-sdk minimum from 0.1.0 to 0.1.39 for better message type support
  • Add rate-limit retry logic to all three chat session _query_claude() methods (spec, assistant, expand) — up to 3 retries with exponential backoff
  • Gracefully handle unknown message types — non-rate-limit MessageParseError is logged as a warning instead of crashing the session
  • Add rate_limited frontend message type with UI handling in all three chat hooks, showing "Rate limited. Retrying in Xs..." system messages

Context

The Claude CLI sends rate_limit_event messages that the SDK's parse_message() doesn't recognize, raising MessageParseError which propagates unhandled through _query_claude() and crashes the entire session.

Test plan

  • ruff check . — all checks passed
  • python test_security.py — 169 passed, 0 failed
  • python -m pytest test_rate_limit_utils.py — 22 passed
  • cd ui && npm run lint — 0 errors
  • cd ui && npm run build — TypeScript compiles and Vite builds successfully

🤖 Generated with Claude Code

leonvanzyl and others added 4 commits February 21, 2026 10:23
…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>
@leonvanzyl leonvanzyl merged commit 9af0f30 into master Feb 23, 2026
2 checks passed
@leonvanzyl leonvanzyl deleted the fix/rate-limit-event-crash branch February 23, 2026 10:28
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