> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Lifecycle hooks

> Observe Go agent runs, model turns, tools, pauses, and completion in real time.

Set `OnEvent` on `RunOptions` or `ContinueOptions` to receive structured lifecycle events without coupling your application to the model transport.

```go theme={null}
result, err := agent.Run(ctx, phaseoagent.RunOptions{
  Input: prompt,
  Client: client,
  OnEvent: func(event phaseoagent.AgentEvent) {
    logger.Info("agent event",
      "type", event.Type,
      "run_id", event.RunID,
      "details", event.Details,
    )
  },
})
```

Useful event families include run start/completion/failure, model attempts, output text and reasoning deltas, tool start/progress/completion/failure, and human checkpoints.

Keep handlers fast and non-blocking. Send events to your own queue or telemetry layer when persistence may take time, and redact sensitive tool inputs before forwarding them externally.
