claude-agent-sdk-python icon indicating copy to clipboard operation
claude-agent-sdk-python copied to clipboard

Cannot Detect `rate_limit` Errors

Open AgentWrapper opened this issue 11 months ago • 0 comments

AssistantMessage.error Not Parsed → Cannot Detect rate_limit Errors

The SDK defines AssistantMessage.error (including "rate_limit"), but the message parser never sets this field. This makes it impossible for applications to detect rate limits or implement retry logic.

Expected

AssistantMessage.error should be populated when the API returns an error.

Actual

The parser only extracts content, model, and parent_tool_use_id; the error field is ignored.

Suggested Fix

Add error parsing, e.g.:

error = data["message"].get("error")
return AssistantMessage(..., error=error)

AgentWrapper avatar Dec 10 '25 12:12 AgentWrapper