handleEvents

Installs the EventHandler feature and configures event handlers for an agent.

This extension function provides a convenient way to install the EventHandler feature and configure various event handlers for an agent. It allows you to define custom behavior for different events that occur during the agent's execution.

Parameters

configure

A lambda with receiver that configures the EventHandlerConfig. Use this to set up handlers for specific events.

Example:

handleEvents {
// Log when tools are called
onToolCall = { stage, tool, toolArgs ->
println("Tool called: ${tool.name}")
}

// Handle errors
onAgentRunError = { strategyName, throwable ->
logger.error("Agent error: ${throwable.message}")
}
}