Annotation Interface P


@Retention(RUNTIME) @Target(PARAMETER) public @interface P
Annotation for parameters of a Tool-annotated method.

Description

value() and description() are aliases for the same thing: the parameter's description that the LLM will see. Use one or the other, but not both at the same time.

When only a description is needed, value can be used as a shorthand:

@Tool
void getWeather(@P("The city name") String city) { ... }

When both a name and a description are needed, use named attributes:

@Tool
void getWeather(@P(name = "city", description = "The city name") String city) { ... }

Name

The name() attribute overrides the parameter name that the LLM will see. This is useful in two cases:
  1. Missing -parameters javac option. Without it (common when not using frameworks like Quarkus or Spring, which enable it by default), Java reflection returns generic names such as arg0, arg1, etc. The semantic meaning of the parameter is lost, which may confuse the LLM. Setting name restores a meaningful name.
  2. Custom name for the LLM. When you want the LLM to see a different parameter name than the one the developer uses in the source code (for example, to match a specific API contract or to provide a more descriptive name).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the parameter.
    Name of the parameter as seen by the LLM.
    boolean
    Whether the parameter is required.
    Description of the parameter.
  • Element Details

    • name

      String name
      Name of the parameter as seen by the LLM.

      If not specified, the actual method parameter name is used (requires the -parameters javac option; otherwise the name defaults to arg0, arg1, etc.).

      Setting this is useful when:

      • The -parameters javac option is not enabled and you want to avoid generic arg0/arg1 names. Note that frameworks like Quarkus and Spring enable -parameters by default, so you typically do not need to set name when using those frameworks.
      • You want the LLM to see a different name than the one in the source code.
      Returns:
      the name of the parameter
      Default:
      ""
    • description

      String description
      Description of the parameter. This is an alias for value(). Use either value or description, but not both.
      Returns:
      the description of the parameter
      Default:
      ""
    • value

      String value
      Description of the parameter. This is an alias for description(). Use either value or description, but not both.

      Convenient for the shorthand form: @P("description here").

      Returns:
      the description of the parameter
      Default:
      ""
    • required

      boolean required
      Whether the parameter is required. Default is true.
      Returns:
      true if the parameter is required, false otherwise
      Default:
      true