AS AgentScopeAPI 手册 / API Reference

RefundOrderTool

public class RefundOrderTool extends ToolBase
源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:41–139

Refund 顺序工具,封装可被智能体调用的能力。位于 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_THRESHOLD
staticfinal
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
staticfinal

ASK 阈值字段。声明为 public static final double ASK_THRESHOLD。

Refunds at or above this amount always require human confirmation.

源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:44

构造器详情Constructor Detail

RefundOrderTool

public RefundOrderTool(WorkbenchStateRegistry registry)

初始化 RefundOrderTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
registryWorkbenchStateRegistry注册表(类型 `WorkbenchStateRegistry`)。The registry.
源码Source 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.

参数Parameters
名称Name类型Type说明Description
toolInputMap<String, Object>工具输入(类型 `Map`)。The tool input.
contextPermissionContextState上下文(类型 `PermissionContextState`)。The context.
返回Returns Mono<PermissionDecision>
返回Mono。Returns mono.
源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:76–91

matchRule

public boolean matchRule(String ruleContent, Map<String, Object> toolInput)

执行 matchRule 方法。

Performs the match rule operation.

参数Parameters
名称Name类型Type说明Description
ruleContentString规则内容(类型 `String`)。The rule content.
toolInputMap<String, Object>工具输入(类型 `Map`)。The tool input.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:93–99

generateSuggestions

public List<PermissionRule> generateSuggestions(Map<String, Object> toolInput)

设置该参数。

Performs the generate suggestions operation.

参数Parameters
名称Name类型Type说明Description
toolInputMap<String, Object>工具输入(类型 `Map`)。The tool input.
返回Returns List<PermissionRule>
返回列出。Returns list.
源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:101–107

callAsync

public Mono<ToolResultBlock> callAsync(ToolCallParam param)

调用异步。

Calls the async.

参数Parameters
名称Name类型Type说明Description
paramToolCallParam参数(类型 `ToolCallParam`)。The param.
返回Returns Mono<ToolResultBlock>
返回Mono。Returns mono.
源码Source io/agentscope/examples/copilotkit/workbench/RefundOrderTool.java:109–122

继承成员Inherited Members

继承自Methods inherited from AgentTool
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.