fix: handle unknown message types (e.g. rate_limit_event) gracefully#72
Merged
RichardAtCT merged 1 commit intoRichardAtCT:mainfrom Feb 20, 2026
Merged
Conversation
The claude-agent-sdk's message parser raises MessageParseError for unrecognised message types like rate_limit_event. This causes the entire request to fail with 'Unknown message type: rate_limit_event'. Instead of letting the error propagate, catch MessageParseError during response iteration and skip the unknown message, allowing the rest of the response (including the actual result) to come through. Fixes RichardAtCT#70
ee5263a to
589afd8
Compare
Owner
|
@claude you happy with this bro? |
|
I'll analyze this and get back to you. |
Owner
|
Thanks for the fix! |
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.

Problem
The
claude-agent-sdk's message parser raisesMessageParseErrorfor unrecognised message types likerate_limit_event. Sincereceive_response()yieldsparse_message(data)without catching this error, it propagates up and kills the entire request with:This affects users on Claude Max/Pro subscriptions where rate limit events are sent inline during streaming.
Fix
Wrap the response iteration in
sdk_integration.pyto catchMessageParseErrorand skip unknown message types rather than failing the entire request. The actual assistant response and result message still come through normally.Testing
Tested on a production deployment with Claude Max subscription — responses now complete successfully with rate limit events silently skipped.
Fixes #70