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 {
onToolCall { stage, tool, toolArgs ->
println("Tool called: ${tool.name} with args $toolArgs")
}

onAgentFinished { strategyName, result ->
println("Agent finished with result: $result")
}
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var onAfterLLMCall: suspend (prompt: Prompt, tools: List<ToolDescriptor>, model: LLModel, responses: List<Message.Response>, sessionUuid: Uuid) -> Unit
Link copied to clipboard
var onAfterNode: suspend (node: AIAgentNodeBase<*, *>, context: AIAgentContextBase, input: Any?, output: Any?) -> Unit
Link copied to clipboard
var onAgentFinished: suspend (strategyName: String, result: String?) -> Unit
Link copied to clipboard
var onAgentRunError: suspend (strategyName: String, sessionUuid: Uuid?, throwable: Throwable) -> Unit
Link copied to clipboard
var onBeforeAgentStarted: suspend (strategy: AIAgentStrategy, agent: AIAgent) -> Unit
Link copied to clipboard
var onBeforeLLMCall: suspend (prompt: Prompt, tools: List<ToolDescriptor>, model: LLModel, sessionUuid: Uuid) -> Unit
Link copied to clipboard
var onBeforeNode: suspend (node: AIAgentNodeBase<*, *>, context: AIAgentContextBase, input: Any?) -> Unit
Link copied to clipboard
var onStrategyFinished: suspend (strategy: AIAgentStrategy, result: String) -> Unit
Link copied to clipboard
var onStrategyStarted: suspend (strategy: AIAgentStrategy) -> Unit
Link copied to clipboard
var onToolCall: suspend (tool: Tool<*, *>, toolArgs: Tool.Args) -> Unit
Link copied to clipboard
var onToolCallFailure: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, throwable: Throwable) -> Unit
Link copied to clipboard
var onToolCallResult: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, result: ToolResult?) -> Unit
Link copied to clipboard
var onToolValidationError: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, value: String) -> Unit

Functions

Link copied to clipboard
Link copied to clipboard
fun onAfterLLMCall(handler: suspend (prompt: Prompt, tools: List<ToolDescriptor>, model: LLModel, responses: List<Message.Response>, sessionUuid: Uuid) -> Unit)

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

Link copied to clipboard
fun onAfterNode(handler: suspend (node: AIAgentNodeBase<*, *>, context: AIAgentContextBase, input: Any?, output: Any?) -> Unit)

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

Link copied to clipboard
fun onAgentFinished(handler: suspend (strategyName: String, result: String?) -> Unit)

Append handler called when an agent finishes execution.

Link copied to clipboard
fun onAgentRunError(handler: suspend (strategyName: String, sessionUuid: Uuid?, throwable: Throwable) -> Unit)

Append handler called when an error occurs during agent execution.

Link copied to clipboard
fun onBeforeAgentStarted(handler: suspend (strategy: AIAgentStrategy, agent: AIAgent) -> Unit)

Append handler called when an agent is started.

Link copied to clipboard
fun onBeforeLLMCall(handler: suspend (prompt: Prompt, tools: List<ToolDescriptor>, model: LLModel, sessionUuid: Uuid) -> Unit)

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

Link copied to clipboard
fun onBeforeNode(handler: suspend (node: AIAgentNodeBase<*, *>, context: AIAgentContextBase, input: Any?) -> Unit)

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

Link copied to clipboard
fun onStrategyFinished(handler: suspend (strategy: AIAgentStrategy, result: String) -> Unit)

Append handler called when a strategy finishes execution.

Link copied to clipboard
fun onStrategyStarted(handler: suspend (strategy: AIAgentStrategy) -> Unit)

Append handler called when a strategy starts execution.

Link copied to clipboard
fun onToolCall(handler: suspend (tool: Tool<*, *>, toolArgs: Tool.Args) -> Unit)

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

Link copied to clipboard
fun onToolCallFailure(handler: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, throwable: Throwable) -> Unit)

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

Link copied to clipboard
fun onToolCallResult(handler: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, result: ToolResult?) -> Unit)

Append handler called when a tool call completes successfully.

Link copied to clipboard
fun onToolValidationError(handler: suspend (tool: Tool<*, *>, toolArgs: Tool.Args, value: String) -> Unit)

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