EventHandlerConfig

Configuration class for the EventHandler feature.

This class provides a way to configure handlers for various events that occur during the execution of an agent. These events include agent lifecycle events, strategy events, node events, LLM call events, and tool call events.

Each handler is a property that can be assigned a lambda function to be executed when the corresponding event occurs.

Example usage:

handleEvents {
onToolCallStarting { eventContext ->
println("Tool called: ${eventContext.tool.name} with args ${eventContext.toolArgs}")
}

onAgentCompleted { eventContext ->
println("Agent finished with result: ${eventContext.result}")
}
}

Constructors

Link copied to clipboard
constructor()

Properties

Functions

Link copied to clipboard
Link copied to clipboard
fun onAfterLLMCall(handler: suspend (AfterLLMCallContext) -> Unit)

Append handler called after a response is received from the language model.

Link copied to clipboard
fun onAfterNode(handler: suspend (NodeAfterExecuteContext) -> Unit)

Append handler called after a node in the agent's execution graph has been processed.

Link copied to clipboard

Appends a handler called before an agent is closed. This allows for additional behavior to be executed prior to the agent being closed.

Link copied to clipboard
fun onAgentClosing(handler: suspend (eventContext: AgentClosingContext) -> Unit)

Appends a handler called before an agent is closed. This allows for additional behavior to be executed prior to the agent being closed.

Link copied to clipboard
fun onAgentCompleted(handler: suspend (eventContext: AgentCompletedContext) -> Unit)

Append handler called when an agent finishes execution.

Link copied to clipboard
fun onAgentExecutionFailed(handler: suspend (eventContext: AgentExecutionFailedContext) -> Unit)

Append handler called when an error occurs during agent execution.

Link copied to clipboard
fun onAgentFinished(handler: suspend (AgentFinishedContext) -> Unit)

Append handler called when an agent finishes execution.

Link copied to clipboard
fun onAgentRunError(handler: suspend (AgentRunErrorContext) -> Unit)

Append handler called when an error occurs during agent execution.

Link copied to clipboard
fun onAgentStarting(handler: suspend (eventContext: AgentStartingContext<*>) -> Unit)

Append handler called when an agent is started.

Link copied to clipboard
fun onBeforeAgentStarted(handler: suspend (AgentStartContext<*>) -> Unit)

Append handler called when an agent is started.

Link copied to clipboard
fun onBeforeLLMCall(handler: suspend (BeforeLLMCallContext) -> Unit)

Append handler called before a call is made to the language model.

Link copied to clipboard
fun onBeforeNode(handler: suspend (NodeBeforeExecuteContext) -> Unit)

Append handler called before a node in the agent's execution graph is processed.

Link copied to clipboard
fun onLLMCallCompleted(handler: suspend (eventContext: LLMCallCompletedContext) -> Unit)

Append handler called after a response is received from the language model.

Link copied to clipboard
fun onLLMCallStarting(handler: suspend (eventContext: LLMCallStartingContext) -> Unit)

Append handler called before a call is made to the language model.

Link copied to clipboard
fun onLLMStreamingCompleted(handler: suspend (eventContext: LLMStreamingCompletedContext) -> Unit)

Registers a handler to be invoked after streaming from a language model completes.

Link copied to clipboard
fun onLLMStreamingFailed(handler: suspend (eventContext: LLMStreamingFailedContext) -> Unit)

Registers a handler to be invoked when an error occurs during streaming.

Link copied to clipboard
fun onLLMStreamingFrameReceived(handler: suspend (eventContext: LLMStreamingFrameReceivedContext) -> Unit)

Registers a handler to be invoked when stream frames are received during streaming.

Link copied to clipboard
fun onLLMStreamingStarting(handler: suspend (eventContext: LLMStreamingStartingContext) -> Unit)

Registers a handler to be invoked before streaming from a language model begins.

Link copied to clipboard
fun onNodeExecutionCompleted(handler: suspend (eventContext: NodeExecutionCompletedContext) -> Unit)

Append handler called after a node in the agent's execution graph has been processed.

Link copied to clipboard

Append handler called when an error occurs during the execution of a node.

Link copied to clipboard
fun onNodeExecutionFailed(handler: suspend (eventContext: NodeExecutionFailedContext) -> Unit)

Append handler called when an error occurs during the execution of a node.

Link copied to clipboard
fun onNodeExecutionStarting(handler: suspend (eventContext: NodeExecutionStartingContext) -> Unit)

Append handler called before a node in the agent's execution graph is processed.

Link copied to clipboard
fun onStrategyCompleted(handler: suspend (eventContext: StrategyCompletedContext<EventHandler>) -> Unit)

Append handler called when a strategy finishes execution.

Link copied to clipboard

Append handler called when a strategy finishes execution.

Link copied to clipboard

Append handler called when a strategy starts execution.

Link copied to clipboard
fun onStrategyStarting(handler: suspend (eventContext: StrategyStartingContext<EventHandler>) -> Unit)

Append handler called when a strategy starts execution.

Link copied to clipboard
fun onToolCall(handler: suspend (ToolCallContext) -> Unit)

Append handler called when a tool is about to be called.

Link copied to clipboard
fun onToolCallCompleted(handler: suspend (eventContext: ToolCallCompletedContext) -> Unit)

Append handler called when a tool call completes successfully.

Link copied to clipboard
fun onToolCallFailed(handler: suspend (eventContext: ToolCallFailedContext) -> Unit)

Append handler called when a tool call fails with an exception.

Link copied to clipboard
fun onToolCallFailure(handler: suspend (ToolCallFailureContext) -> Unit)

Append handler called when a tool call fails with an exception.

Link copied to clipboard
fun onToolCallResult(handler: suspend (ToolCallResultContext) -> Unit)

Append handler called when a tool call completes successfully.

Link copied to clipboard
fun onToolCallStarting(handler: suspend (eventContext: ToolCallStartingContext) -> Unit)

Append handler called when a tool is about to be called.

Link copied to clipboard

Append handler called when a validation error occurs during a tool call.

Link copied to clipboard
fun onToolValidationFailed(handler: suspend (eventContext: ToolValidationFailedContext) -> Unit)

Append handler called when a validation error occurs during a tool call.

Link copied to clipboard