← 返回 Skills 市场
paibwhgs

Adaptive Tool Filter

作者 paibwhgs · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
450
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install adaptive-tool-filter
功能描述
智能识别用户意图,动态筛选并优先排序相关工具,降低token消耗提升响应效率。
使用说明 (SKILL.md)

自适应工具过滤 Skill

智能过滤工具列表,减少 token 消耗,提高响应效率。

功能

  1. 意图识别 - 根据用户输入识别任务意图
  2. 工具匹配 - 筛选与意图相关的工具
  3. 优先级排序 - 按相关性排序工具列表
  4. 动态调整 - 根据对话进展调整工具集

设计原理

参考 LightAgent 的自适应工具机制:

  • 不是所有工具都需要在每次请求中加载
  • 根据任务类型动态过滤
  • 减少不必要的 token 消耗

意图分类

意图类型 相关工具 触发信号
文件操作 read, write, edit, exec "读取"、"写入"、"文件"、"保存"
网络搜索 web_search, web_fetch, browser "搜索"、"查找"、"网页"、"链接"
消息发送 message, sessions_send "发送"、"通知"、"消息"、"飞书"
飞书操作 feishu_doc, feishu_bitable_* "飞书"、"文档"、"表格"、"知识库"
Agent 管理 sessions_spawn, subagents "子Agent"、"协作"、"并行"
节点操作 nodes "节点"、"手机"、"设备"
系统命令 exec, process "运行"、"执行"、"命令"、"安装"

过滤规则

规则 1:关键词匹配

INTENT_TOOLS = {
    'file': ['read', 'write', 'edit'],
    'web': ['web_search', 'web_fetch', 'browser'],
    'feishu': ['feishu_doc', 'feishu_bitable_*', 'feishu_wiki'],
    'message': ['message', 'sessions_send'],
    'agent': ['sessions_spawn', 'subagents', 'sessions_list'],
    'system': ['exec', 'process'],
}

def filter_tools(user_input: str, all_tools: list) -> list:
    # 检测意图
    detected_intents = detect_intent(user_input)
    
    # 筛选相关工具
    relevant_tools = []
    for intent in detected_intents:
        relevant_tools.extend(INTENT_TOOLS.get(intent, []))
    
    # 添加通用工具(始终需要)
    core_tools = ['memory_search', 'memory_get', 'read', 'write']
    
    return core_tools + relevant_tools

规则 2:上下文继承

对话进行中,保留之前使用的工具:

  • 如果上一步用了 feishu_doc,下一步可能还需要
  • 但可以移除不再需要的工具(如已完成的 web_search

规则 3:安全边界

某些工具需要特别处理:

  • exec - 需要用户明确允许
  • edit - 检查文件是否在工作区

System Prompt 集成

## 工具管理

每次请求前,智能筛选工具:

1. 分析用户输入关键词
2. 识别任务意图类型
3. 筛选相关工具集
4. 排序:核心工具 → 相关工具 → 可选工具
5. 控制工具数量(建议 ≤ 20 个)

意图检测信号:
- 文件相关:"读取"、"写入"、"文件"、"保存"、"创建"
- 网络相关:"搜索"、"查找"、"网页"、"链接"、"在线"
- 飞书相关:"飞书"、"文档"、"表格"、"多维表格"、"知识库"
- 消息相关:"发送"、"通知"、"消息"、"回复"
- Agent相关:"子Agent"、"协作"、"并行"、"启动"

效果对比

无过滤

可用工具:50+ 个
Token 消耗:每次请求 ~5000 tokens(工具定义)
响应时间:较长(模型需要评估所有工具)

有过滤

可用工具:10-20 个
Token 消耗:每次请求 ~1500 tokens
响应时间:更快(模型只评估相关工具)

实现建议

OpenClaw 可以在以下层面实现:

1. 配置层面

openclaw.json 中配置意图-工具映射:

{
  "toolFilter": {
    "intents": {
      "file": ["read", "write", "edit"],
      "web": ["web_search", "web_fetch"],
      "feishu": ["feishu_*"]
    }
  }
}

2. Skill 层面

创建 tool-filter Skill,在请求前自动过滤。

3. 运行时层面

在 Agent 运行时动态调整工具集。


参考 LightAgent 自适应工具机制设计

安全使用建议
This skill is coherent and low-risk as-is because it only contains guidance and no installs or credentials. Before enabling it: review which tools your agent exposes and ensure sensitive tools (exec, process, sessions_spawn, any file-write or remote-posting tools) require explicit, per-action confirmation; avoid automatic persistence of previously used dangerous tools across turns; test the filter in a sandboxed agent with a limited toolset to verify it doesn't unintentionally allow escalation or automated spawning of subagents.
功能分析
Type: OpenClaw Skill Name: adaptive-tool-filter Version: 1.0.0 The skill bundle is a documentation-based guide (SKILL.md) designed to optimize AI agent performance by filtering the toolset based on user intent. It contains no executable code, exfiltration logic, or malicious prompt injections; instead, it provides logical frameworks and system prompt instructions to reduce token consumption, even explicitly mentioning security boundaries for sensitive tools like 'exec'.
能力评估
Purpose & Capability
The name/description (adaptive tool filtering to reduce tokens and prioritize tools) matches the SKILL.md content and example logic. Required resources (none) align with an instruction-only design.
Instruction Scope
Instructions stay within filtering/intent-detection scope. They recommend preserving previously used tools and special handling for sensitive tools (e.g., require explicit permission for 'exec', check files for 'edit'). This is reasonable, but the 'preserve previous tools' rule can unintentionally keep dangerous tools enabled across turns if not strictly controlled.
Install Mechanism
No install spec and no code files — nothing is written to disk or downloaded. This is the lowest-risk installation model and matches the skill's intent.
Credentials
The skill declares no environment variables, no credentials, and no config paths. There is nothing disproportionate requested for the stated purpose.
Persistence & Privilege
The skill is not always:true and does not request persistent system changes. However it explicitly recommends retaining previously used tools and references agent-management tools (sessions_spawn/subagents). Those capabilities are powerful if enabled in the platform — ensure they remain subject to user consent and policy controls.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install adaptive-tool-filter
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /adaptive-tool-filter 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of adaptive-tool-filter skill. - Implements intent recognition from user input to intelligently filter and prioritize tool lists. - Dynamically adjusts available tools during conversation to improve efficiency and reduce token consumption. - Provides configurable intent-to-tool mapping and supports context inheritance for tool selection. - Adds safety checks for sensitive tools (e.g., exec, edit). - Integrated system prompt for consistent tool management and optimized system performance. ## 注意事项 - 本 Skill 仅提供优化建议 - 具体实现需要 OpenClaw 运行时支持 - 配置修改前请备份原文件
元数据
Slug adaptive-tool-filter
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Adaptive Tool Filter 是什么?

智能识别用户意图,动态筛选并优先排序相关工具,降低token消耗提升响应效率。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 450 次。

如何安装 Adaptive Tool Filter?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install adaptive-tool-filter」即可一键安装,无需额外配置。

Adaptive Tool Filter 是免费的吗?

是的,Adaptive Tool Filter 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Adaptive Tool Filter 支持哪些平台?

Adaptive Tool Filter 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Adaptive Tool Filter?

由 paibwhgs(@paibwhgs)开发并维护,当前版本 v1.0.0。

💬 留言讨论