Tool

interface Tool : ToolInfo

Framework-agnostic tool that can be invoked by an LLM. Adapters in SPI layer bridge to Spring AI ToolCallback or LangChain4j ToolSpecification/ToolExecutor.

All nested types are scoped within this interface to avoid naming conflicts with framework-specific types (e.g., Spring AI's ToolDefinition, ToolMetadata).

Inheritors

Types

Link copied to clipboard
interface Definition

Framework-agnostic tool definition.

Link copied to clipboard
fun interface Function

Functional interface for simple tool implementations.

Link copied to clipboard

Java-friendly functional interface for tool implementations. Uses handle method name which is more idiomatic in Java than invoke.

Link copied to clipboard
interface InputSchema

Input schema for a tool, supporting both simple and complex parameters.

Link copied to clipboard
interface Metadata

Optional metadata about a tool's behavior.

Link copied to clipboard
data class Parameter constructor(val name: String, val type: Tool.ParameterType, val description: String = name, val required: Boolean = true, val enumValues: List<String>? = null, val properties: List<Tool.Parameter>? = null, val itemType: Tool.ParameterType? = null)

A single parameter for a tool.

Link copied to clipboard

Supported parameter types.

Link copied to clipboard
sealed interface Result

Result of tool execution with optional artifacts.

Properties

Link copied to clipboard

Tool definition for LLM

Link copied to clipboard

Optional metadata

Functions

Link copied to clipboard
abstract fun call(input: String): Tool.Result

Execute the tool with JSON input.

Link copied to clipboard
inline fun <T : Any> Tool.requireType(message: String? = null): Tool

Wrap this tool to require a value of type T before execution (reified).

fun <T : Any> Tool.requireType(type: Class<T>, messageProvider: (String) -> String? = { null }): Tool

Wrap this tool to require a value of type T before execution.

Link copied to clipboard
fun Tool.toSpringToolCallback(): <Error class: unknown class>

Extension function to convert an Embabel Tool to a Spring AI ToolCallback.

Link copied to clipboard
inline fun <T : Tool> Tool.unwrapAs(): T?

Unwrap a tool to find a specific type, or return null if not found.

Link copied to clipboard

Wrap this tool to conditionally await before execution.

Link copied to clipboard
fun Tool.withConfirmation(messageProvider: (String) -> String): Tool

Wrap this tool to always require confirmation before execution.

Link copied to clipboard
open fun withDescription(newDescription: String): Tool

Create a new tool with a different description. Useful for providing context-specific descriptions while keeping the same functionality.

Link copied to clipboard
fun Tool.withEventPublication(agentProcess: AgentProcess, action: Action?, llmOptions: <Error class: unknown class>): Tool

Extension function to wrap a Tool with event publication.

Link copied to clipboard
open fun withName(newName: String): Tool

Create a new tool with a different name. Useful for namespacing tools when combining multiple tool sources.

Link copied to clipboard
open fun withNote(note: String): Tool

Create a new tool with an additional note appended to the description. Useful for adding context-specific hints to an existing tool.