> ## 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.

# Lebenszyklus-Hooks

> Beobachte Go-Agent-Läufe, Modellzüge, Tools, Pausen und den Abschluss in Echtzeit.

Setze `OnEvent` in `RunOptions` oder `ContinueOptions`, um strukturierte Lifecycle-Ereignisse zu erhalten, ohne deine Anwendung an den Modelltransport zu koppeln.

```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,
    )
  },
})
```

Nützliche Ereignisgruppen umfassen Start, Abschluss und Fehler eines Laufs, Modellversuche, Text- und Reasoning-Änderungen sowie Start, Fortschritt, Abschluss und Fehler von Tools und menschliche Prüfpunkte.

Halte Handler schnell und nicht blockierend. Sende Ereignisse an eine eigene Warteschlange oder Telemetrieebene, wenn das Speichern länger dauern kann, und schwärze sensible Tool-Eingaben vor der externen Weitergabe.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.