Tool Use & Function Calling

How do you handle tool call errors gracefully?

QUICK ANSWER

To report a tool execution failure to Claude, return a user message block with the parameter 'is_error' set to true. This tells Claude the tool failed, prompting the model to fix its input arguments.

Error Response Block

{
  "type": "tool_result",
  "tool_use_id": "toolu_12345",
  "content": "Database error: connection timed out.",
  "is_error": true
}
Verified against: Anthropic API Tool Use v1