toolResult
Converts a tool and its corresponding result into a ReceivedToolResult object.
This utility function simplifies the creation of tool results for testing purposes. It automatically handles the encoding of the result into the appropriate string format.
Return
A ReceivedToolResult instance containing the tool's name and the encoded string representation of the result.
Example usage:
// Create a tool result for testing
val result = toolResult(AnalyzeTool, AnalyzeTool.Result("Detailed analysis", 0.95))
// Use in node output assertions
assertNodes {
callTool withInput toolCallSignature(AnalyzeTool, AnalyzeTool.Args("analyze")) outputs result
}Parameters
The tool whose result is being processed. The tool provides context for the result.
The result produced by the tool, which will be encoded into a string representation.
Constructs a ReceivedToolResult object using the provided tool and result string.
This is a convenience function for simple tools that return text results. It wraps the string result in a ToolResult.Text object.
Return
An instance of ReceivedToolResult containing the tool's name and the result string.
Example usage:
// Create a simple text tool result for testing
val result = toolResult(SolveTool, "solved")
// Use in node output assertions
assertNodes {
callTool withInput toolCallSignature(SolveTool, SolveTool.Args("solve")) outputs result
}Parameters
The tool for which the result is being created, of type SimpleTool.
The result content generated by the tool execution as a string.