Testing
Provides functionality for testing graph-related stages in an AI agent pipeline.
This feature allows you to configure and validate the relationships between nodes, their outputs, and the overall graph structure within different stages of an agent. It can validate:
Stage order
Node existence and reachability
Node input/output behavior
Edge connections between nodes
The Testing feature is designed to be used with the testGraph function, which provides a clean API for defining and executing graph tests.
Example usage:
AIAgent(
// constructor arguments
) {
testGraph {
// Assert the order of stages
assertStagesOrder("first", "second")
// Test the first stage
stage("first") {
val start = startNode()
val finish = finishNode()
// Assert nodes by name
val askLLM = assertNodeByName<String, Message.Response>("callLLM")
val callTool = assertNodeByName<ToolCall.Signature, ToolCall.Result>("executeTool")
// Assert node reachability
assertReachable(start, askLLM)
assertReachable(askLLM, callTool)
// Test node behavior
assertNodes {
askLLM withInput "Hello" outputs Message.Assistant("Hello!")
}
// Test edge connections
assertEdges {
askLLM withOutput Message.Assistant("Hello!") goesTo giveFeedback
}
}
}
}
See also
Types
Represents a configuration class responsible for managing assertion handlers and stage configurations. It includes methods for registering custom assertion handling, managing stages and their order, and defining stage-specific assertions.
Companion object that defines the Testing
feature as a AIAgentFeature
. This feature provides testing capabilities for validating graph-based stages, nodes, reachability, outputs, and edges within an AI agent pipeline.