This page documents Laravel events that LarAgent dispatches. For in-class hooks that can modify agent behavior, see Agent Hooks.
Lifecycle Events
AgentInitialized
Dispatched when the agent completes its initialization process and is ready to handle conversations.Complete agent configuration including provider, tools, instructions, and response schema.
ConversationStarted
Dispatched when therespond() method begins execution, marking the start of a new conversation turn.
Current agent configuration at the start of the conversation.
ConversationEnded
Dispatched when therespond() method completes execution.
Final agent configuration at the end of the conversation.
The final response message or null if no response was generated.
ToolChanged
Dispatched when tools are dynamically added to or removed from the agent during runtime.Current agent configuration.
The tool instance that was added or removed.
true if the tool was added, false if it was removed.AgentCleared
Dispatched when the agentβs state is cleared, typically resetting conversation history and context.Agent configuration at the time of clearing.
EngineError
Dispatched when an error occurs in the LLM engine during processing.Agent configuration when the error occurred.
The exception that was thrown by the LLM engine.
Hook Events
These events provide hooks before and after critical operations.BeforeReinjectingInstructions
Dispatched before instructions are reinjected into the conversation history.Current agent configuration.
The chat history interface before instruction reinjection.
BeforeSend / AfterSend
Dispatched before and after adding a message to chat history.Current agent configuration.
The conversation history.
The message being sent.
BeforeResponse / AfterResponse
Dispatched before sending to and after receiving from the LLM.Current agent configuration.
The message (user message for Before, LLM response for After).
BeforeToolExecution / AfterToolExecution
Dispatched before and after a tool is executed.Current agent configuration.
The tool instance being executed.
The tool call with
getId, getToolName, and getArguments methods.(AfterToolExecution only) The result returned by the tool.
BeforeSaveHistory
Dispatched before persisting the conversation history to storage.Current agent configuration.
The conversation history about to be saved.
BeforeStructuredOutput
Dispatched before processing structured output from the LLM response.Current agent configuration including the response schema.
The raw structured response array before processing.

