Annotation Interface Tool


Marks a method as a tool in Spring AI.
Since:
1.0.0
Author:
Thomas Vitale
  • Element Details

    • name

      String name
      The name of the tool. If not provided, the method name will be used.

      For maximum compatibility across different LLMs, it is recommended to use only alphanumeric characters, underscores, hyphens, and dots in tool names. Using spaces or special characters may cause issues with some LLMs (e.g., OpenAI).

      Examples of recommended names: "get_weather", "search-docs", "tool.v1"

      Examples of names that may cause compatibility issues: "get weather" (contains space), "tool()" (contains parentheses)

      Default:
      ""
    • description

      String description
      The description of the tool. If not provided, the method name will be used.
      Default:
      ""
    • returnDirect

      boolean returnDirect
      Whether the tool result should be returned directly or passed back to the model.
      Default:
      false
    • resultConverter

      Class<? extends ToolCallResultConverter> resultConverter
      The class to use to convert the tool call result to a String.
      Default:
      org.springframework.ai.tool.execution.DefaultToolCallResultConverter.class