Typed Tool
Tool with strongly typed input and output. Handles JSON marshaling automatically, allowing you to work with domain objects directly.
Example usage:
data class AddRequest(val a: Int, val b: Int)
data class AddResult(val sum: Int)
val addTool = TypedTool(
name = "add",
description = "Add two numbers",
inputType = AddRequest::class.java,
outputType = AddResult::class.java,
) { input -> AddResult(input.a + input.b) }Parameters
Input type - will be deserialized from JSON
Output type - will be serialized to JSON (unless it's already a Tool.Result)
Tool name for LLM consumption
Tool description for LLM consumption
Class of the input type for JSON deserialization
Class of the output type (used for documentation)
Optional tool metadata
ObjectMapper for JSON serialization/deserialization
Function that processes typed input and returns typed output
Inheritors
Constructors
Functions
Executes the tool by deserializing input JSON, calling typedCall, and serializing the result.
Extension function to convert an Embabel Tool to a Spring AI ToolCallback.
Wrap this tool to conditionally await before execution.
Wrap this tool to always require confirmation before execution.
Create a new tool with a different description. Useful for providing context-specific descriptions while keeping the same functionality.
Extension function to wrap a Tool with event publication.