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

Recover from tool errors

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

Understand PHP execution

PHP tool callbacks execute synchronously. Tool concurrency and interruption are therefore constrained by the PHP runtime and the underlying I/O client. Use explicit timeouts in network and process tools, and avoid claiming that a timed-out callback can always be forcibly stopped.

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. Use lifecycle hooks or DevTools instead of logging raw prompts and credentials.
Last modified on July 26, 2026