Skip to content

Failing well

Two different kinds of wrong

A protocol error means the conversation itself broke: a method that does not exist, a malformed frame, a transport that died.

A tool failure means the conversation worked perfectly and the answer is that the thing could not be done. Dividing by zero is the second kind, not the first.

Why a model needs the difference

A tool failure comes back as a successful response carrying isError, so the model can read it, understand what went wrong, and try something else.

Throwing instead hides that. The model is told the machinery broke, when really it just asked for something impossible.

What to do

Register divide with a and b. When b is zero, return content explaining the problem and set isError to true rather than throwing.

Run it and watch the theatre: the failure is drawn in red, but it is still a response, not an error frame.

Written against revision 2026-07-28

Add a tool called divide that returns the quotient, and refuses to divide by zero by reporting a tool failure rather than throwing.

Tab indents. Press Escape then Tab to leave the editor.

draft saved
Press Run to compile this in the sandbox and watch the session.