QuestionQ42

Tool Design & MCP Integration

The track_shipment(tracking_id) tool calls an external logistics API that can occasionally fail—the API may be temporarily unavailable, the tracking ID may be malformed, or the shipment may not exist. The tool currently raises a Python exception when an error occurs. Users report that the agent gives unhelpful replies such as “I’m having trouble with that request,” rather than suggesting alternatives like checking the tracking-number format or looking up the shipment by order number. How should errors in tool results be handled?

Explanation

Structured error output lets the agent distinguish transient service failures from invalid tracking IDs and missing shipments, determine whether recovery is possible, and give the user an appropriate next step. Including an error category, recoverability indicator, and actionable context preserves useful information without relying on exceptions as the agent-facing interface.

Community Discussion

No comments yet. Be the first to start the discussion!