All Lessons

A tool throws an exception during execution. How should the application report this back so Claude can react gracefully?

1 / 3
advanced 20 min

Tool Error Handling

Loading lesson content...

Scenario: Customer Support Resolution Agent You are building a customer support resolution agent using the Claude Agent SDK. The agent handles high-ambiguity requests like returns, billing disputes, and account issues. It has access to backend systems through MCP tools (get_customer, lookup_order, process_refund, escalate_to_human). Your target is 80%+ first-contact resolution while knowing when to escalate. Your customer support agent calls three MCP tools during a typical session: get_customer (which returns account creation dates as Unix timestamps like 1704067200), lookup_order (which returns order dates in ISO 8601 format like "2024-01-01T00:00:00Z"), and process_refund (which returns a numeric status code like 1, 2, or 3 representing "approved," "pending," and "rejected" respectively). In production, the agent frequently misinterprets these values, confusing timestamp formats and describing status code 2 as "completed" instead of "pending." A teammate suggests adding a sentence to the system prompt explaining each tool's output format and asking Claude to interpret them correctly. You need to decide how to address this data normalization problem reliably. What is the most appropriate architectural approach?

1 / 3