Annotation Interface ToolParam


@Retention(RUNTIME) @Target({PARAMETER,RECORD_COMPONENT}) public @interface ToolParam
Describes a parameter of a Tool-annotated method. The name() and description() are surfaced to the model; required() controls whether the model must supply a value.

Set name() explicitly: reflection only recovers parameter names when the -parameters javac flag is enabled, and otherwise returns arg0, arg1, etc. — which the model can't meaningfully use.

Example:

@Tool("Looks up the current weather for a city.")
public String getWeather(
    @ToolParam(name = "city", description = "City name, e.g. 'Folsom'") String city,
    @ToolParam(name = "units", description = "'metric' or 'imperial'", required = false)
        String units) {
  ...
}
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Parameter description surfaced to the model.
    Parameter name surfaced to the model.
    boolean
    Whether the parameter is required.
  • Element Details

    • name

      String name
      Parameter name surfaced to the model. Defaults to the reflected parameter name; set this explicitly unless the build passes -parameters to javac.
      Default:
      ""
    • description

      String description
      Parameter description surfaced to the model.
      Default:
      ""
    • required

      boolean required
      Whether the parameter is required. Defaults to true.
      Default:
      true