Chapter 7: Errors, Recovery, Learning
Tools return errors. APIs time out. Files don't exist. Code doesn't compile. In a long agentic session, something breaks on almost every loop iteration. Error handling isn't an edge case. It's the main case.
The simplest error handler: try again. And again. And again. Each retry burns tokens. The model re-reads the entire context, generates the same failing call, and gets the same error. Five retries at $0.03 each adds up fast.
Manus's counterintuitive insight: inject the full error message into context and let the model try a different approach. The error is information. Hiding it causes blind retries. Showing it enables adaptation.
Bad: retry same tool 5x. Good: show error, switch strategy.
Click any node to trace the recovery path. Every error forks into a decision: retry with same tool, switch to a different tool, degrade gracefully, or escalate to the human. The tree encodes your error policy.
When a tool fails 3 times in a row, trip the breaker. Stop sending requests to it. After a cooldown, try once more (half-open). If it works, reset. If not, keep it open. Borrowed from microservices, essential for agents.
When tools fail, the agent should step down through capability levels. Full power → reduced tools → minimal output → fallback message. A partial answer is infinitely better than a cryptic error. The user always gets something useful.