Annotation Type AIToolMethod


@Retention(RUNTIME) @Target(METHOD) public @interface AIToolMethod
Annotation used to mark a static method as a tool (function) that can be called by the AI model.

Methods annotated with @AIToolMethod are automatically discovered by the ToolManager and exposed to the Gemini API as function declarations.

Author:
Anahata
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    A detailed, human-readable description of what the tool does.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Defines how the output of this tool should be treated within the chat context.
    boolean
    Determines whether the user must explicitly approve the execution of this tool via a confirmation dialog.
  • Element Details

    • value

      String value
      A detailed, human-readable description of what the tool does. This description is sent to the model to help it understand when and how to use the tool.
      Returns:
      The tool description.
    • requiresApproval

      boolean requiresApproval
      Determines whether the user must explicitly approve the execution of this tool via a confirmation dialog.

      Set to false for safe, read-only operations (e.g., reading a file). Defaults to true for safety.

      Returns:
      true if approval is required, false otherwise.
      Default:
      true
    • behavior

      ContextBehavior behavior
      Defines how the output of this tool should be treated within the chat context.

      Use ContextBehavior.EPHEMERAL for one-off actions and ContextBehavior.STATEFUL_REPLACE for tools that return persistent resources like file contents.

      Returns:
      The context behavior.
      Default:
      EPHEMERAL