Writing effective tools for AI agents
- ID: a4f8f998
- 原文链接: https://www.anthropic.com/research/writing-tools-for-agents
- 作者: Anthropic
- 日期: 2025-09
- 更新: N/A
- 分类: agents
- 来源类型: article
- 标签: tools, agent-design, context-management, tool-descriptions, best-practices
- 质量评分: 5/5
- 抓取时间: 2026-11-03T15:47:11Z
中文导读
Anthropic 2025-09 的 agent 工具设计指南:agent 卡住时瓶颈更多在工具接口而非模型反模式是把现有 API 原样包一层list_contacts 拉全量等于逼 agent 在上下文里过滤;应合并高频动作为少数复合工具描述与 schema 整体进上下文,措辞即提示词:Claude 曾总在搜索 query 末尾补 2025,改描述才纠正;精修描述曾让 Sonnet 3.5 登顶 SWE-bench Verified校验失败要给可执行的改进建议,别给裸错误码同一 Slack 帖子详细版 206 token精简版 72 token
为什么值得关注
agent 工程里被引用最多的工具设计参考之一:把'改工具比换模型便宜'讲成了有数字的工程方法——token 标尺(206 vs 72)、可测的精度影响(SWE-bench 精修)、可直接抄的反模式清单(API 原样包装、裸错误码、全量列表返回)。配合 Trace-Free+ 一类自动化改写研究食用,是从手工调优到自动化接口优化的完整路径。
关键信息
- 发布:Anthropic 工程博客,2025 年 9 月;现路径 https://www.anthropic.com/research/writing-tools-for-agents (自 /engineering/writing-tools-for-agents 308 重定向,2026-11-03 验证 200)
- 反模式:把现有软件 API 端点原样包一层——传统软件内存便宜无上下文限制,list_contacts 拉全量再过滤没有成本;agent 上下文有限,同样做等于逼它从头翻通讯录
- 合并高频动作:schedule_event = 查空档 + 建日程;get_customer_context = 一次带回客户近期交易 + 备注;read_logs → search_logs 只返回命中行 + 少量上下文
- 描述即提示词:web search 上线后 Claude 总在 query 末尾补 "2025" 带偏结果,靠修改工具描述纠正;SWE-bench Verified 上对工具描述精修后 Sonnet 3.5 拿到当时 SOTA
- 错误信息即提示词:校验失败要返回可执行的改进建议,别给裸错误码——agent 会照错误文本走下一步
- 体量标尺:同一 Slack 帖子详细版 206 token、精简版 72 token(约 1/3);Claude Code 默认把工具响应截在 25,000 token
- 字段命名:避免 uuid / 256px_image_url / mime_type 这类底层技术标识符,name / image_url / file_type 更能直接支撑 agent 下游动作;thread_ts 等 ID 由 detailed 响应按需提供
English Summary
Anthropic's September 2025 engineering guide: when agents get stuck, the tool interface is more often the bottleneck than the model. Do not wrap existing APIs verbatim - list_contacts dumping a full contact list forces the agent to filter in-context; consolidate frequent flows into fewer composite tools (schedule_event checks availability and books; search_logs returns matching lines with limited context). Descriptions are prompts: after launching web search, Claude kept appending '2025' to queries until the description was fixed; precise refinements to tool descriptions let Sonnet 3.5 reach then-SOTA on SWE-bench Verified. Return actionable error messages, not bare codes - agents follow the error text. Size matters: the same Slack thread is 206 tokens detailed vs 72 concise; Claude Code caps tool responses at 25,000 tokens; descriptive fields beat uuid-style identifiers.
Obsidian Notes
- 内容获取路径:curl -L 抓取 https://www.anthropic.com/research/writing-tools-for-agents 全文 HTML(约 233KB),关键 claim(list_contacts/schedule_event 合并、web search 补 2025、SWE-bench Verified、206/72 token、25,000 token 上限、uuid 类标识符)逐条在页面文本中命中。
- 原文日期仅精确到月(2025-09),按 schema 部分日期写入。
- 现代站点生成器按
content/{entry.id}.md查找内容页;本文件写入 canonical content 目录,而不是openclaw/content/。