Skip to content

API Error: 400 - messages.2.content.0.tool_result: content cannot be empty if is_error is true #248

@moz-mdauer

Description

@moz-mdauer

I'm working on a multi-agent system using the Claude Agent SDK and after some time, I consistently encounter the following error, which is breaking the entire system:

UserMessage(content=[ToolResultBlock(tool_use_id='', content='', is_error=True)], parent_tool_use_id=None)
AssistantMessage(content=[TextBlock(text='API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.2.content.0.tool_result: content cannot be empty if `is_error` is true"},"request_id":""}')], model='<synthetic>', parent_tool_use_id=None)
ResultMessage(subtype='success', duration_ms=28092, duration_api_ms=29761, is_error=True, num_turns=4, session_id='', total_cost_usd=0.07331955, usage={'input_tokens': 3, 'cache_creation_input_tokens': 11627, 'cache_read_input_tokens': 11933, 'output_tokens': 1133, 'server_tool_use': {'web_search_requests': 0}, 'service_tier': 'standard', 'cache_creation': {'ephemeral_1h_input_tokens': 0, 'ephemeral_5m_input_tokens': 11627}}, result='API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.2.content.0.tool_result: content cannot be empty if `is_error` is true"},"request_id":""}')

It's unclear whether this issue originates from the SDK or the API itself, but opening the issue here for visibilty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions