Annotation Interface AgentTool
Marks a method as an AI Agent Tool.
Methods annotated with @AgentTool will be available for the AI agent to use when processing user requests. The agent will call these tools based on the user's intent and the tool description.
Example usage:
public class MyPluginTools implements AgentToolProvider {
@AgentTool(
name = "get_weather",
description = "Get the current weather for a location",
keywords = {"weather", "temperature", "forecast"}
)
public String getWeather(AgentToolContext context, String location) {
return "The weather in " + location + " is sunny, 25°C";
}
}
Tool methods must:
- Have
AgentToolContextas the first parameter - Return a String (the tool's response to the agent)
- Only use primitive types, String, or simple objects for other parameters
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPermission levels for agent tools. -
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionDescription of what the tool does. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether this tool requires DM context.booleanWhether this tool requires guild context.String[]Keywords that help identify when this tool should be used.The unique name of the tool.Permission level required to use this tool.intPriority for tool selection when multiple tools match.
-
Element Details
-
name
String nameThe unique name of the tool. If not specified, the method name will be used.- Returns:
- tool name
- Default:
""
-
description
String descriptionDescription of what the tool does. This is shown to the AI agent to help it decide when to use the tool. Should be clear and concise.- Returns:
- tool description
-
keywords
String[] keywordsKeywords that help identify when this tool should be used. The agent may use these to better match user intent.- Returns:
- array of keywords
- Default:
{}
-
guildOnly
boolean guildOnlyWhether this tool requires guild context. If true, the tool will only be available in guild channels.- Returns:
- true if guild-only
- Default:
false
-
dmOnly
boolean dmOnlyWhether this tool requires DM context. If true, the tool will only be available in direct messages.- Returns:
- true if DM-only
- Default:
false
-
permission
AgentTool.ToolPermission permissionPermission level required to use this tool. Can be used for access control.- Returns:
- required permission level
- Default:
EVERYONE
-
priority
int priorityPriority for tool selection when multiple tools match. Higher priority tools are preferred.- Returns:
- priority (default 0)
- Default:
0
-