DummyTool
class DummyTool(name: String = "dummy_tool", description: String = "A dummy tool for testing.", isLongRunning: Boolean = false, declares: Boolean = false, val onRun: suspend (context: ToolContext, args: Map<String, Any?>) -> Any = { _, _ ->
mapOf("status" to "done")
}) : BaseTool
A highly configurable dummy implementation of BaseTool for testing purposes.
This fixture is designed to be a fully reusable and configurable BaseTool. Instead of creating standalone inline tool classes per test, developers can pass an onRun lambda to define the specific simulated logic.
Example usage:
// Simulating a straightforward return value
val dummy = DummyTool { _, _ -> "success" }
// Simulating state modification
val dummyWithState = DummyTool { context, _ ->
context.actions.stateDelta["key"] = "value"
"done"
}
// Simulating exceptions
val failingDummy = DummyTool { _, _ -> throw Exception("Simulated error") }Content copied to clipboard
Parameters
name
The name of the tool. Defaults to "dummy_tool".
description
The description of the tool. Defaults to "A dummy tool for testing.".
onRun
The suspendable lambda that simulates the run method execution. It receives the ToolContext and arguments map, and must return the tool's result. Defaults to returning a successful "status" mapped to "done".
declares
Whether declaration returns a FunctionDeclaration, so the model is offered the tool. Defaults to false.