Interface Tool

  • All Implemented Interfaces:
    com.embabel.agent.api.tool.ToolInfo

    
    public interface Tool
     implements 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).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface Tool.Definition

      Framework-agnostic tool definition.

      public interface Tool.InputSchema

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

      public final class Tool.Parameter

      A single parameter for a tool.

      public enum Tool.ParameterType

      Supported parameter types.

      public interface Tool.Metadata

      Optional metadata about a tool's behavior.

      public interface Tool.Result

      Result of tool execution with optional artifacts.

      public interface Tool.Function

      Functional interface for simple tool implementations.

      public interface Tool.Handler

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

      public class Tool.Companion
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Tool.Result call(String input) Execute the tool with JSON input.
      Tool withName(String newName) Create a new tool with a different name.
      Tool withDescription(String newDescription) Create a new tool with a different description.
      Tool withNote(String note) Create a new tool with an additional note appended to the description.
      • Methods inherited from class com.embabel.agent.api.tool.ToolInfo

        getDefinition, getMetadata
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • call

         abstract Tool.Result call(String input)

        Execute the tool with JSON input.

        Parameters:
        input - JSON string matching inputSchema
        Returns:

        Result to send back to LLM

      • withName

         Tool withName(String newName)

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

        Parameters:
        newName - The new name to use
        Returns:

        A new Tool with the updated name

      • withDescription

         Tool withDescription(String newDescription)

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

        Parameters:
        newDescription - The new description to use
        Returns:

        A new Tool with the updated description

      • withNote

         Tool withNote(String note)

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

        Parameters:
        note - The note to append to the description
        Returns:

        A new Tool with the note appended to its description