ToolParam
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface ToolParam
io/agentscope/core/tool/ToolParam.java:59–104用于标记工具参数相关元数据的注解。位于 io.agentscope.core.tool 包。核心成员包括 name、required、description。
Annotation to describe parameters of a tool method.
This annotation is required for all parameters of methods annotated with Tool (except
ToolEmitter which is auto-injected). It provides metadata for generating JSON schemas
that describe the tool's parameters to LLMs.
Usage Example:
`@Tool(name = "calculate_area", description = "Calculate rectangle area")
public double calculateArea(
@ToolParam(name = "width", description = "Width in meters", required = true)
double width,
@ToolParam(name = "height", description = "Height in meters", required = true)
double height,
@ToolParam(name = "unit", description = "Unit of measurement", required = false)
String unit
) {
// Implementation
}
`
Important Notes:
-
The
nameattribute is required because Java does not preserve parameter names at runtime by default -
Parameter names should follow snake_case convention for LLM compatibility
-
Descriptions help the LLM understand what values to provide
-
ToolEmitterparameters do not need this annotation (they are framework-injected)
注解元素摘要Annotation Element Summary
| 元素Element | 类型Type | 默认值Default | 说明Description |
|---|---|---|---|
required | boolean | true | 判断是否此参数是必填。 Whether this parameter is required. |
description | String | "" | 返回 `description` 结果。 The description of this parameter. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String name() | 工具参数的名称。 The name of the tool parameter. |
注解元素详情Annotation Element Detail
required
public boolean required()
判断是否此参数是必填。
Whether this parameter is required.
booleanio/agentscope/core/tool/ToolParam.java:87description
public String description()
返回 description 结果。
The description of this parameter.
Stringio/agentscope/core/tool/ToolParam.java:103方法详情Method Detail
name
public String name()
工具参数的名称。
The name of the tool parameter.
Stringio/agentscope/core/tool/ToolParam.java:76