In pi’s loop, no failure path throws. Unknown tools, invalid arguments, blocked permissions, and tool execution exceptions all become error tool-result messages fed back to the model, letting the model correct itself on the next turn. The LLM stream function is contractually required to encode its own failures as messages with stopReason “error” rather than rejecting. Errors become data the conversation can recover from, instead of exceptions that crash the session.

Related: