Interface LLMProvider.ToolSpec

Enclosing interface:
LLMProvider

public static interface LLMProvider.ToolSpec
A framework-agnostic tool definition that the LLM can invoke.

Unlike vendor-specific tool annotations (e.g., LangChain4j's @Tool, Spring AI's @Tool), this interface allows tools to be defined programmatically without depending on any specific AI framework.

Tool definitions are typically provided by AIController implementations through their AIController.getTools() method.

  • Method Summary

    Modifier and Type
    Method
    Description
    execute(tools.jackson.databind.JsonNode arguments)
    Executes the tool with the given arguments.
    Gets a human-readable description of what this tool does.
    Gets the unique name of this tool.
    Gets the JSON Schema describing the parameters this tool accepts.
  • Method Details

    • getName

      String getName()
      Gets the unique name of this tool. The name must contain only alphanumeric characters, underscores, and hyphens, with a maximum length of 64 characters (matching the pattern ^[a-zA-Z0-9_-]{1,64}$), as required by popular LLM APIs. Names that do not match this pattern will be rejected by the orchestrator at request time. To avoid name collisions, use a namespaced name such as "MyController_updateConfig".
      Returns:
      the tool name, never null or empty
    • getDescription

      String getDescription()
      Gets a human-readable description of what this tool does. This description is sent to the LLM to help it decide when to invoke the tool.
      Returns:
      the tool description, never null
    • getParametersSchema

      String getParametersSchema()
      Gets the JSON Schema describing the parameters this tool accepts. The schema should follow the JSON Schema specification.

      Example:

       {
         "type": "object",
         "properties": {
           "query": { "type": "string", "description": "The SQL query" }
         },
         "required": ["query"]
       }
       
      Returns:
      the JSON Schema string, or null if the tool takes no parameters
    • execute

      String execute(tools.jackson.databind.JsonNode arguments)
      Executes the tool with the given arguments.

      Implementations should return a human-readable result string on success. On failure, they may throw any runtime exception.

      Parameters:
      arguments - the tool arguments as a JsonNode matching the parameters schema
      Returns:
      the result of the tool execution as a string, never null