# onEvent

open suspend override fun onEvent(invocationContext: InvocationContext, event: Event): Event

Callback executed when an event is yielded by an agent during execution.

This is the ideal place to modify the event before it is persisted to the session service and yielded to the caller. Useful for logging events or transforming them before they reach the final consumer.

#### Return

The potentially modified Event to propagate downstream.

#### Parameters

invocationContext

The context for the entire invocation.

event

The event raised by the runner.