Skip to main content

Overview

The agent emits events throughout its lifecycle. Events are read-only observations — they cannot modify agent behavior (use hooks for that). Two ways to observe events:
  • wiretap(callable): Receives every event — AgentEventConsoleObserver uses this internally
  • onEvent(EventClass, callable): Subscribes to a specific event type for custom logic
Both can be used together. The logger provides general visibility while onEvent() lets you collect metrics, trigger side effects, or react to specific events. Key concepts:
  • AgentEventConsoleObserver: Built-in wiretap that formats all events for console output
  • onEvent(): Targeted listener for a single event class
  • Events include: AgentStepCompleted, ToolCallStarted, ToolCallCompleted, InferenceResponseReceived, AgentExecutionCompleted, ContinuationEvaluated, and more

Example