Annotation Interface Tool
Marks a method as a tool in Spring AI.
- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe description of the tool.The name of the tool.Class<? extends ToolCallResultConverter>
The class to use to convert the tool call result to a String.boolean
Whether the tool result should be returned directly or passed back to the model.
-
Element Details
-
name
String nameThe 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 descriptionThe description of the tool. If not provided, the method name will be used.- Default:
- ""
-
returnDirect
boolean returnDirectWhether the tool result should be returned directly or passed back to the model.- Default:
- false
-
resultConverter
Class<? extends ToolCallResultConverter> resultConverterThe class to use to convert the tool call result to a String.- Default:
- org.springframework.ai.tool.execution.DefaultToolCallResultConverter.class
-