ToolFilter
public final class ToolFilter
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
allowis non-empty, catalogued tools not listed are removed. -
HarnessPlatformToolsnames always surviveallow(Harness runtime must keep working). Explicitdenystill removes them. -
denyentries are always removed, regardless ofallow. -
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)
判断是否已允许。
Returns whether a tool with name survives cfg's allow/deny rules.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
cfg | ToolsConfig | cfg(类型 `ToolsConfig`)。The cfg. |
booleanio/agentscope/harness/agent/tools/ToolFilter.java:55–80apply
public static void apply(Toolkit toolkit, ToolsConfig cfg)
执行 apply 方法。
Removes tools from toolkit that are excluded by cfg's allow/deny lists.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
cfg | ToolsConfig | cfg(类型 `ToolsConfig`)。The cfg. |
io/agentscope/harness/agent/tools/ToolFilter.java:86–140