withTesting

Enables and configures the Testing feature for a Kotlin AI Agent instance.

This function installs the Testing feature with the specified configuration. It's typically used within the agent constructor block to enable testing capabilities.

Parameters

config

A lambda function to configure the Testing feature. The default is an empty configuration.

Example usage:

// Create an agent with testing enabled
AIAgent(
promptExecutor = mockLLMApi,
toolRegistry = toolRegistry,
strategy = strategy,
eventHandler = eventHandler,
agentConfig = agentConfig,
) {
// Enable testing with custom configuration
withTesting {
enableGraphTesting = true
handleAssertion { assertionResult ->
// Custom assertion handling
}
}
}

See also