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 (response: String) -> Unit

Handler called after a response is received from the language model.

Link copied to clipboard

Handler called after a response with tool calls is received from the language model.

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

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

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

Handler called when an agent finishes execution.

Link copied to clipboard
var onAgentRunError: suspend (strategyName: String, throwable: Throwable) -> Unit

Handler called when an error occurs during agent execution.

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

Handler called when an agent is created.

Link copied to clipboard
var onBeforeLLMCall: suspend (prompt: Prompt) -> Unit

Handler called before a call is made to the language model.

Link copied to clipboard
var onBeforeLLMWithToolsCall: suspend (prompt: Prompt, tools: List<ToolDescriptor>) -> Unit

Handler called before a call is made to the language model with tools.

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

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

Link copied to clipboard
var onStrategyFinished: suspend (strategyName: String, result: String) -> Unit

Handler called when a strategy finishes execution.

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

Handler called when a strategy starts execution.

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

Handler called when a tool is about to be called.

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

Handler called when a tool call fails with an exception.

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

Handler called when a tool call completes successfully.

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

Handler called when a validation error occurs during a tool call.

Functions

Link copied to clipboard