AS AgentScopeAPI 手册 / API Reference

ToolFilter

public final class ToolFilter
源码Source io/agentscope/harness/agent/tools/ToolFilter.java:44–152

工具过滤器,让智能体以受控方式调用外部能力。位于 io.agentscope.harness.agent.tools 包。核心成员包括 isAllowed、apply。

Applies the allow (ToolsConfig#getAllow()) / deny (ToolsConfig#getDeny()) lists from workspace/tools.json (or Managed Agents toolset export) against a Toolkit.

Semantics:

  • When allow is non-empty, catalogued tools not listed are removed.

  • HarnessPlatformTools names always survive allow (Harness runtime must keep working). Explicit deny still removes them.

  • deny entries are always removed, regardless of allow.

  • When both are empty/absent the toolkit is left untouched.

Names that don't correspond to a currently registered tool are logged at WARN and otherwise ignored — typos in the workspace file should not abort the agent.

方法摘要Method Summary

方法Method说明Description
public static boolean isAllowed(String name, ToolsConfig cfg)
static
判断是否已允许。
Returns whether a tool with `name` survives `cfg`'s allow/deny rules.
public static void apply(Toolkit toolkit, ToolsConfig cfg)
static
执行 `apply` 方法。
Removes tools from `toolkit` that are excluded by `cfg`'s allow/deny lists.

方法详情Method Detail

isAllowed

public static boolean isAllowed(String name, ToolsConfig cfg)
static

判断是否已允许。

Returns whether a tool with name survives cfg's allow/deny rules.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
cfgToolsConfigcfg(类型 `ToolsConfig`)。The cfg.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/tools/ToolFilter.java:55–80

apply

public static void apply(Toolkit toolkit, ToolsConfig cfg)
static

执行 apply 方法。

Removes tools from toolkit that are excluded by cfg's allow/deny lists.

参数Parameters
名称Name类型Type说明Description
toolkitToolkit工具包(类型 `Toolkit`)。The toolkit.
cfgToolsConfigcfg(类型 `ToolsConfig`)。The cfg.
源码Source io/agentscope/harness/agent/tools/ToolFilter.java:86–140
基于官方固定版本源码静态生成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.