onEvent callback to receive structured lifecycle events while the run executes.
Observe
Lifecycle hooks
Observe PHP agent runs, model turns, tools, pauses, and completion.
Pass an
Useful events cover run start/completion/failure, model attempts, text and reasoning deltas, tool start/progress/completion/failure, and human checkpoints.
Keep callbacks fast. Queue slow persistence work, and redact sensitive tool inputs before forwarding events to external telemetry.
Last modified on July 26, 2026