Errors the model can use
When a tool fails, its message is the model's only clue.
In MCP's Python SDK, a plain exception reaches the model as just “Error executing tool”. Raise ToolError and your message gets through.
- model calls
- 1
- tool calls
- 0
- tokens in
- 191
- tokens out
- 20
- time
- 1.1s
Task Where is my order A12?
Model call 1. It read 191 tokens and wrote 20. It asked for a tool, so it isn't done.
get_order({"order_id":"A12"})
stop_reason: tool_use
Context window
191 tokens sent
- Your messages6
- Tool definitions157
- System prompt28
0.02% of the 10,48,576-token window. Every call sends all of it again.
Context window191 tokens sent
- System prompt28
- Tool definitions157
- Your messages6
You are gemini-3-flash-preview. This is all you know: 262 tokens.
System prompt
You are QuickCart's support agent. Use the tools to look up real order data. Never guess. Be brief and kind.
Your tools
- get_order Look up an order by its id. Returns status, tracking id and the promised delivery date.
- find_orders List the ids of this customer's recent orders.
- track_shipment Where a shipment is right now, by tracking id. Returns status, location and the latest delivery estimate.
User
Where is my order A12?
You called
get_order("A12")
get_order returned
Error executing tool get_order
Your move?
The same server raising ToolError. The model is told what's wrong and what to call next:
- model calls
- 1
- tool calls
- 0
- tokens in
- 191
- tokens out
- 20
- time
- 1.1s
Task Where is my order A12?
Model call 1. It read 191 tokens and wrote 20. It asked for a tool, so it isn't done.
get_order({"order_id":"A12"})
stop_reason: tool_use
Context window
191 tokens sent
- Your messages6
- Tool definitions157
- System prompt28
0.02% of the 10,48,576-token window. Every call sends all of it again.
Context window191 tokens sent
- System prompt28
- Tool definitions157
- Your messages6
Your MCP tool can't find an order. What should it do?