Skip to content

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.

An error the model can't usegemini-3-flash-previewRecorded real run
model calls
1
tool calls
0
tokens in
191
tokens out
20
time
1.1s

Task Where is my order A12?

You
task
Model1.1s
get_order
find_orders
track_shipment

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 window191 tokens sent

  • System prompt28
  • Tool definitions157
  • Your messages6
step 1 of 9
Be the modelAn error the model can't use
0/1 best

You are gemini-3-flash-preview. This is all you know: 262 tokens.

  1. System prompt

    You are QuickCart's support agent. Use the tools to look up real order data. Never guess. Be brief and kind.

  2. 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.
  3. User

    Where is my order A12?

  4. You called

    get_order("A12")

  5. 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:

An error the model can usegemini-3-flash-previewRecorded real run
model calls
1
tool calls
0
tokens in
191
tokens out
20
time
1.1s

Task Where is my order A12?

You
task
Model1.1s
get_order
find_orders
track_shipment

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 window191 tokens sent

  • System prompt28
  • Tool definitions157
  • Your messages6
step 1 of 9

Your MCP tool can't find an order. What should it do?