Bug
When the Claude Code CLI emits a rate_limit_event message (informational,
CLI handles retry internally), the Python SDK crashes with MessageParseError
instead of ignoring it.
Versions
- claude-agent-sdk (Python): 0.1.39
- @anthropic-ai/claude-agent-sdk (TypeScript): 0.2.50
Steps to reproduce
Run any query using the Python SDK. If the CLI encounters a temporary rate
limit (burst/minute limits), it emits a rate_limit_event to the stream.
Expected behavior
The event should be silently ignored, as the CLI already handles the wait/retry
internally. The TypeScript SDK (v0.2.50) does this correctly.
Actual behavior
MessageParseError: Unknown message type: rate_limit_event is raised,
terminating the query prematurely.
Root cause
In _internal/query.py, _read_messages() does not filter rate_limit_event
before passing messages to the stream. It then reaches message_parser.py which
falls into case _: raise MessageParseError(...).
Fix
Add a continue for rate_limit_event in query.py, similar to how
control_cancel_request is handled:
elif msg_type == "rate_limit_event":
# CLI handles rate limiting internally — skip informational event
continue
---
Bug
When the Claude Code CLI emits a
rate_limit_eventmessage (informational,CLI handles retry internally), the Python SDK crashes with
MessageParseErrorinstead of ignoring it.
Versions
Steps to reproduce
Run any query using the Python SDK. If the CLI encounters a temporary rate
limit (burst/minute limits), it emits a
rate_limit_eventto the stream.Expected behavior
The event should be silently ignored, as the CLI already handles the wait/retry
internally. The TypeScript SDK (v0.2.50) does this correctly.
Actual behavior
MessageParseError: Unknown message type: rate_limit_eventis raised,terminating the query prematurely.
Root cause
In
_internal/query.py,_read_messages()does not filterrate_limit_eventbefore passing messages to the stream. It then reaches
message_parser.pywhichfalls into
case _: raise MessageParseError(...).Fix
Add a
continueforrate_limit_eventinquery.py, similar to howcontrol_cancel_requestis handled: