Skip to main content
Agent failures normally come from the model request, a local tool, schema validation, a timeout, or an incomplete human decision.

Recover from tool errors

Set on_error: "return-to-model" when the model can recover from a tool failure. The error becomes a tool result and the agent can choose another action. Keep fail-run behavior for unsafe or unrecoverable operations.

Understand Ruby execution

Ruby consumes model streams through normal synchronous iteration. Use explicit timeouts for network and process tools, and avoid blocking lifecycle callbacks with slow persistence work.

Diagnose continuation errors

Every pending call needs an approval, rejection, or externally supplied output keyed by its tool-call ID. Persist the complete returned run state before showing an approval UI.

Log actionable fields

Capture run ID, step index, request ID, provider, model, finish reason, tool-call ID, and stop reason. Prefer lifecycle hooks or DevTools to raw prompt logging.
Last modified on July 26, 2026