Pruning an Agent’s Tool Surface with Progressive Disclosure
A report presents a runnable Python 3.12 implementation for reducing the tools exposed to an agent: filter candidates by task group, use a flat one-line index, load full schemas on demand, and downweight tools that repeatedly fail. Its tool_pruner.py uses a deterministic keyword selector and a character-based token estimate, so the comparisons demonstrate relative scale rather than model performance or actual billing. The report attributes Anthropic guidance that dynamic exposure can be worthwhile when tool definitions exceed 10K tokens, more than 10 tools are available, or tool-selection errors occur, while benefits may be limited with fewer tools or when every session needs all tools.
The report provides a concrete client-side exposure strategy that can reduce unnecessary tool descriptions and selection interference without changing the MCP protocol. It also states important limits: the example is not a production model evaluation, feedback downweighting requires reliable signals, and dynamic exposure does not replace authorization, auditing, or sandboxing.
摘要:面向已经接入多个 MCP 服务器、工具数从个位数涨到几十个的 Agent 开发者与架构师。工具挂载得越多,模型选错工具的概率越高、上下文 token 越贵——问题不在模型,在"工具面(tool surface)"的暴露策略。本文给出一套「工具面三收」方法:按任务收、按层级收、按反馈收,并附一份可运行 Python 3.12 脚本
tool_pruner.py,实现按任务组过滤、一层扁平索引、按需加载正文、失败工具降权与 token 对照自测。附两张能力对照表和适用边界,可直接照搬为工具注册层的前置裁剪。
一、问题背景:工具接得越多,Agent 反而越容易选错
一个常见的演进路径是这样的:起初给 Agent 挂 6 个工具(文件读写、终端、网页抓取、数据库查询、消息通知),每次都能干净利落地选对;后来接了 GitHub、Jira、Notion、PostgreSQL、向量检索、日志分析等,工具数涨到 30 个,同样一句 prompt,首次选对的工具开始频繁出错,token 账单和重试成本一起往上走。
#Anthropic#Tool Search Tool#Model Context Protocol#Agent Skills#Claude Opus 4#Claude Opus 4.5#tool_pruner.py