Annotation 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
Thename() attribute overrides the parameter name that the LLM will see.
This is useful in two cases:
- Missing
-parametersjavac option. Without it (common when not using frameworks like Quarkus or Spring, which enable it by default), Java reflection returns generic names such asarg0,arg1, etc. The semantic meaning of the parameter is lost, which may confuse the LLM. Settingnamerestores a meaningful name. - 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
-
Element Details
-
name
String nameName of the parameter as seen by the LLM.If not specified, the actual method parameter name is used (requires the
-parametersjavac option; otherwise the name defaults toarg0,arg1, etc.).Setting this is useful when:
- The
-parametersjavac option is not enabled and you want to avoid genericarg0/arg1names. Note that frameworks like Quarkus and Spring enable-parametersby default, so you typically do not need to setnamewhen 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:
""
- The
-
description
-
value
String valueDescription of the parameter. This is an alias fordescription(). Use eithervalueordescription, but not both.Convenient for the shorthand form:
@P("description here").- Returns:
- the description of the parameter
- Default:
""
-
required
boolean requiredWhether the parameter is required. Default istrue.- Returns:
trueif the parameter is required,falseotherwise
- Default:
true
-