RefundOrderTool
public class RefundOrderTool extends ToolBase
io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:41–139Refund 顺序工具,封装可被智能体调用的能力。位于 io.agentscope.examples.copilotkit.workbench 包,继承自 ToolBase。核心成员包括 checkPermissions、matchRule、generateSuggestions、callAsync、RefundOrderTool、ASK_THRESHOLD。
Refund tool demonstrating AgentScope's built-in checks: the permission decision depends on the actual arguments rather than on a static rule.
Small refunds run straight through, anything at or above {@value #ASK_THRESHOLD} needs a human,
and refunds without an order id are rejected outright. Because built-in checks run inside the tool
they cannot be bypassed by PermissionMode.BYPASS or by an allow rule — which is exactly the
point of the demo.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
ASK_THRESHOLDstaticfinal | double | ASK 阈值字段。 Refunds at or above this amount always require human confirmation. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public RefundOrderTool(WorkbenchStateRegistry registry) | 初始化 `RefundOrderTool` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context) | 检查权限。 Performs the check permissions operation. |
public boolean matchRule(String ruleContent, Map<String, Object> toolInput) | 执行 `matchRule` 方法。 Performs the match rule operation. |
public List<PermissionRule> generateSuggestions(Map<String, Object> toolInput) | 设置该参数。 Performs the generate suggestions operation. |
public Mono<ToolResultBlock> callAsync(ToolCallParam param) | 调用异步。 Calls the async. |
字段详情Field Detail
ASK_THRESHOLD
public static final double ASK_THRESHOLD
ASK 阈值字段。声明为 public static final double ASK_THRESHOLD。
Refunds at or above this amount always require human confirmation.
io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:44构造器详情Constructor Detail
RefundOrderTool
public RefundOrderTool(WorkbenchStateRegistry registry)
初始化 RefundOrderTool 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
registry | WorkbenchStateRegistry | 注册表(类型 `WorkbenchStateRegistry`)。The registry. |
io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:50–61方法详情Method Detail
checkPermissions
public Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context)
检查权限。
Performs the check permissions operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolInput | Map<String, Object> | 工具输入(类型 `Map`)。The tool input. |
context | PermissionContextState | 上下文(类型 `PermissionContextState`)。The context. |
Mono<PermissionDecision>io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:76–91matchRule
public boolean matchRule(String ruleContent, Map<String, Object> toolInput)
执行 matchRule 方法。
Performs the match rule operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ruleContent | String | 规则内容(类型 `String`)。The rule content. |
toolInput | Map<String, Object> | 工具输入(类型 `Map`)。The tool input. |
booleanio/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:93–99generateSuggestions
public List<PermissionRule> generateSuggestions(Map<String, Object> toolInput)
设置该参数。
Performs the generate suggestions operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolInput | Map<String, Object> | 工具输入(类型 `Map`)。The tool input. |
List<PermissionRule>io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:101–107callAsync
public Mono<ToolResultBlock> callAsync(ToolCallParam param)
调用异步。
Calls the async.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
param | ToolCallParam | 参数(类型 `ToolCallParam`)。The param. |
Mono<ToolResultBlock>io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:109–122