Learn how to use Agent lifecycle events to customize behavior
onInitialize
hook is called when the agent is fully initialized. This is the perfect place to set up any initial state or configurations your agent needs.
Example: Set temperature dynamically based on user preferences
respond
method call, signaling the start of a new step in conversation. Use this to prepare conversation-specific resources or logging.
Example: Log conversation start
respond
method, this hook allows you to perform cleanup, logging or any other logic your application might need after a conversation ends. In case of streaming, it runs at the last chunk received.
Example: Save conversation history
true
) or removed (false
).
Example: Update tool metadata
toDTO
method: $this->toDTO()
EventServiceProvider
: