← Back to Skills Marketplace
paibwhgs

Adaptive Tool Filter

by paibwhgs · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
450
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install adaptive-tool-filter
Description
智能识别用户意图,动态筛选并优先排序相关工具,降低token消耗提升响应效率。
README (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 自适应工具机制设计

Usage Guidance
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.
Capability Analysis
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'.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install adaptive-tool-filter
  3. After installation, invoke the skill by name or use /adaptive-tool-filter
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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 运行时支持 - 配置修改前请备份原文件
Metadata
Slug adaptive-tool-filter
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Adaptive Tool Filter?

智能识别用户意图,动态筛选并优先排序相关工具,降低token消耗提升响应效率。 It is an AI Agent Skill for Claude Code / OpenClaw, with 450 downloads so far.

How do I install Adaptive Tool Filter?

Run "/install adaptive-tool-filter" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Adaptive Tool Filter free?

Yes, Adaptive Tool Filter is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Adaptive Tool Filter support?

Adaptive Tool Filter is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Adaptive Tool Filter?

It is built and maintained by paibwhgs (@paibwhgs); the current version is v1.0.0.

💬 Comments