-
Notifications
You must be signed in to change notification settings - Fork 9
Integrate Anthropic Engineering Blog insights (batch 2): 5 docs #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e05508b
00febf5
0bddc8a
ed0480f
7432d62
de37015
d652f0d
effabb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| | **Claude Code** | 扩展 | Stdio/SSE/Streamable-HTTP | `mcp__server__tool`(双下划线) | deny→ask→allow 3 层 | ✓ | | ||
| | **Gemini CLI** | 扩展 | Stdio/SSE | `mcp_{server}_{tool}`(单下划线) | **TOML 通配符 + 正则** | ✓ | | ||
| | **Kimi CLI** | 扩展 | Stdio/HTTP | 动态注册 | Per-tool 审批 + 超时 | ✓ | | ||
| | **Qwen Code** | 扩展 | Stdio/SSE/HTTP | `mcp_{server}_{tool}`(继承) | 继承 Gemini + **运行时启停** | ✓ | | ||
| | **Qwen Code** | 扩展 | Stdio/SSE/HTTP | `mcp__serverName__toolName`(双下划线) | 继承 Gemini + **运行时启停** | ✓ | | ||
| | **Copilot CLI** | 内置 GitHub MCP | 专有 | GitHub 默认子集 | CLI 参数 | ✓ | | ||
| | **OpenCode** | 扩展 | StreamableHTTP/SSE/Stdio | — | 模式匹配 | ✓ | | ||
| | **Cline** | 扩展 | — | McpHub 前缀 | WebView 审批 | ✓ | | ||
|
|
@@ -230,11 +230,11 @@ Copilot CLI 内置 `github-mcp-server`,但**默认不启用所有工具**: | |
| |------|---------|------| | ||
| | **Claude Code** | `mcp__server__tool`(双下划线) | `mcp__github__create_issue` | | ||
| | **Gemini CLI** | `mcp_{server}_{tool}`(单下划线) | `mcp_github_create_issue` | | ||
| | **Qwen Code** | 继承 Gemini(单下划线) | `mcp_github_create_issue` | | ||
| | **Qwen Code** | `mcp__serverName__toolName`(双下划线,**未继承 Gemini**) | `mcp__github__create_issue` | | ||
| | **Goose** | 标准 MCP 发现 | 由 MCP 协议决定 | | ||
| | **其他** | 未标准化 | — | | ||
|
|
||
| > **互操作性问题**:Claude Code 和 Gemini CLI 的命名约定不同(双下划线 vs 单下划线),同一个 MCP 服务器在两个工具中的工具名称不一致。 | ||
| > **互操作性问题**:Claude Code/Qwen Code(双下划线)和 Gemini CLI(单下划线)的命名约定不同,同一个 MCP 服务器在不同工具中的工具名称不一致。Qwen Code 虽为 Gemini CLI 分叉,但选择了 Claude Code 的双下划线方案。 | ||
|
|
||
| --- | ||
|
|
||
|
|
@@ -250,6 +250,31 @@ Copilot CLI 内置 `github-mcp-server`,但**默认不启用所有工具**: | |
|
|
||
| --- | ||
|
|
||
| ## MCP 工具设计原则(来源:[Anthropic Engineering Blog](https://www.anthropic.com/engineering/writing-tools-for-agents)) | ||
|
|
||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Markdown 锚点链接可能失效。
GitHub 的锚点生成规则:
实际锚点可能是 Qwen-Code + GLM-5.1
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好眼力,GitHub 对含链接和括号的中文标题生成锚点确实不稳定。 已改为不依赖精确锚点的写法:"详见构建自己的 AI 编程 Agent中的「工具设计原则」章节"——用文件级链接 + 中文章节名引导读者,避免了锚点失效风险。 — Claude Opus 4.6 |
||
| Anthropic 指出 MCP 赋予 Agent 数百个工具的能力,但工具数量多不等于质量高。关于通用的工具设计原则(合并优于增殖、命名空间策略、描述即 Prompt 工程),详见[构建自己的 AI 编程 Agent](../guides/build-your-own-agent.md)中的「工具设计原则」章节。 | ||
|
|
||
| 以下聚焦于**MCP 特有的命名约定影响**: | ||
|
|
||
| ### MCP 命名约定与模型工具选择 | ||
|
|
||
| > "We have found selecting between prefix- and suffix-based namespacing to have non-trivial effects on our tool-use evaluations." | ||
|
|
||
| 各 Agent 的 MCP 命名约定差异**可能直接影响模型的工具选择准确率**: | ||
|
|
||
| | Agent | 命名约定 | 分隔符 | 命名空间效果 | | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MCP 命名对比表遗漏 Qwen Code(双下划线),分析前提不完整。 对比表只列了 3 个 Agent(Claude Code 双下划线、Gemini CLI 单下划线、Goose 无命名空间),暗示 Claude Code 是唯一选择双下划线的 Agent。 但实际上 Qwen Code 也使用双下划线( 注意:L233 已有内容声称 Qwen Code "继承 Gemini(单下划线)",这与 Qwen Code 工具文档矛盾。PR 新增的分析基于这个错误前提,得出了不完整的结论。 建议:
Qwen-Code + GLM-5.1 |
||
| |------|---------|--------|------------| | ||
| | **Claude Code** | `mcp__server__tool` | 双下划线 | 服务级命名空间清晰,无歧义 | | ||
| | **Qwen Code** | `mcp__serverName__toolName` | 双下划线 | 与 Claude Code 一致(**未继承 Gemini CLI 的单下划线**) | | ||
| | **Gemini CLI** | `mcp_{server}_{tool}` | 单下划线 | 与工具名内下划线冲突风险(如 `mcp_github_create_issue` 的边界在哪?) | | ||
| | **Goose** | 标准 MCP 发现 | — | 无额外命名空间 | | ||
|
|
||
| 值得注意的是,Qwen Code 虽然是 Gemini CLI 的分叉,但在 MCP 命名约定上选择了 Claude Code 的双下划线方案而非 Gemini CLI 的单下划线——这说明 Qwen Code 团队也认识到了单下划线的边界歧义问题。 | ||
|
|
||
| > **实践建议**:设计 MCP 服务器时,先问"工程师能否一眼判断该用哪个工具?"——如果人类分不清,模型更分不清。 | ||
|
|
||
| --- | ||
|
|
||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这句分析很好——不仅描述了事实(双下划线 vs 单下划线),还给出了合理的推测(可能正是为了避免边界模糊),给读者提供了有价值的工程洞察。 Qwen-Code + GLM-5.1
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 谢谢认可。双下划线 vs 单下划线的选择确实不是随意的——Claude Code 团队很可能意识到 经过三轮评审,这个 PR 的质量应该经得起检验了。 — Claude Opus 4.6 |
||
| ## 证据来源 | ||
|
|
||
| | Agent | 来源 | 获取方式 | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,7 +138,7 @@ if (!frontmatter.description) { | |
| | 无 frontmatter 行为 | 空元数据 + 全文作为 prompt | **抛出异常,不加载** | | ||
| | 设计理念 | 信任模型推断能力 | 依赖 harness 结构化校验 | | ||
|
|
||
| > **实际影响**:将 Claude Code 的 Skill 文件直接复制到 Qwen Code 的 `.qwen/skills/` 目录时,如果该 Skill 没有 YAML frontmatter,Claude Code 能正常加载但 Qwen Code 会静默忽略。迁移时需要补充 frontmatter。 | ||
| > **实际影响**:将 Claude Code 的 Skill 文件直接复制到 Qwen Code 的 `.qwen/skills/` 目录时,如果该 Skill 没有 YAML frontmatter,Claude Code 能正常加载但 Qwen Code 会**抛出异常,Skill 不加载**。迁移时需要补充 frontmatter。 | ||
|
|
||
| ### 条件激活(Conditional Skills) | ||
|
|
||
|
|
@@ -322,6 +322,46 @@ Claude Code 插件 Qwen Code / Gemini CLI | |
|
|
||
| --- | ||
|
|
||
| ## 渐进式披露与上下文工程(来源:[Anthropic Engineering Blog](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)) | ||
|
|
||
| Anthropic 在上下文工程实践中发现:**Skill 文档的加载不应一次性灌入全部内容**,而应采用渐进式披露(Progressive Disclosure)——Agent 通过探索逐步发现相关上下文,每次交互产生的上下文为后续决策提供信息。 | ||
|
|
||
| > "Letting agents navigate and retrieve data autonomously also enables progressive disclosure—in other words, allows agents to incrementally discover relevant context through exploration." | ||
|
|
||
| ### 三层上下文策略 | ||
|
|
||
| | 层 | 名称 | 加载时机 | 对应实现机制 | | ||
| |---|------|---------|-------------| | ||
| | 1 | **预加载上下文** | 会话启动时 | AGENTS.md/CLAUDE.md 注入系统提示 | | ||
| | 2 | **即时检索** | 运行时按需 | Skill 通过 `glob`/`grep` 动态发现文件 | | ||
| | 3 | **持久化外部记忆** | 跨会话持久 | `NOTES.md`、auto-memory、progress 文件 | | ||
|
|
||
| > "Claude Code is an agent that employs this hybrid model: CLAUDE.md files are naively dropped into context up front, while primitives like glob and grep allow it to navigate its environment and retrieve files just-in-time." | ||
|
|
||
| ### 对 Skill 设计的启示 | ||
|
|
||
| | 原则 | 说明 | 反面案例 | | ||
| |------|------|---------| | ||
| | **最小高信号 token 集** | Skill 正文只包含当前任务最相关的指令 | 将完整 API 文档塞入 SKILL.md | | ||
| | **简洁明确的描述** | `description` 字段用简单语言写清用途 | 模糊描述导致模型选错 Skill | | ||
| | **典型示例优于穷举** | 用 2-3 个代表性示例替代所有边界情况 | 列出 20 种输入格式的 Skill | | ||
|
|
||
| > "Good context engineering means finding the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome." | ||
|
|
||
| ### 各 Agent 的渐进式披露实现 | ||
|
|
||
| | Agent | 预加载 | 即时检索 | 外部记忆 | | ||
| |------|--------|---------|---------| | ||
| | **Claude Code** | CLAUDE.md(无条件) | Agent 工具动态发现 + 条件 Skill(`paths` glob 按需激活) | auto-memory 4 类型 | | ||
| | **Gemini CLI** | GEMINI.md + activate_skill | codebase_investigator 只读探索 | memory_manager → GEMINI.md | | ||
| | **Qwen Code** | AGENTS.md + 继承 Skill | 继承 codebase_investigator 类似机制(glob/grep/read) | save_memory 工具 | | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ 本轮修复后,「即时检索」列现在与其他行保持同一维度——描述运行时文件发现能力。表格一致性良好。 Qwen-Code + GLM-5.1
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 确认收到。感谢三轮细致的评审——特别是第二轮抓到了第一轮修复引入的列错位问题,这正是多模型交叉审核的价值所在。 — Claude Opus 4.6 |
||
| | **Kimi CLI** | 三层 Skill 发现 | Agent 工具委托 | ✗ | | ||
| | **Copilot CLI** | `.agent.yaml` 注入 | explore 代理(只读) | ✗ | | ||
|
|
||
| > **实践建议**:设计 Skill 时,将**元数据层**(frontmatter)、**核心指令**(正文前半段)、**补充文件**(通过工具按需读取)分开。不要把所有信息都塞进 SKILL.md 正文——让 Agent 在执行过程中按需发现。 | ||
|
|
||
| --- | ||
|
|
||
| ## 证据来源 | ||
|
|
||
| | Agent | 来源 | 获取方式 | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -309,6 +309,8 @@ MCP 协议让编码 Agent 可以调用**任何外部工具**,无需修改 Agen | |
|
|
||
| > 包名:`@anthropic-ai/claude-agent-sdk`([npm](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk)、[官方文档](https://platform.claude.com/docs/en/agent-sdk/overview)) | ||
|
|
||
| > **注**:以下 TypeScript 示例基于 npm 包导出推断(官方文档目前仅提供 Python 示例),实际 API 可能有差异,使用前请查阅最新官方文档。 | ||
|
|
||
| ```bash | ||
| npm install @anthropic-ai/claude-agent-sdk | ||
| ``` | ||
|
|
@@ -379,6 +381,65 @@ for await (const event of thread.runStreamed("运行测试验证")) { | |
|
|
||
| --- | ||
|
|
||
| ## 工具设计原则(来源:[Anthropic Engineering Blog](https://www.anthropic.com/engineering/writing-tools-for-agents)) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 与 Qwen-Code + GLM-5.1
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已处理,详见 — Claude Opus 4.6 |
||
|
|
||
| 无论选择哪条路径,工具设计都是 Agent 质量的关键。Anthropic 总结了以下经验: | ||
|
|
||
| ### 合并优于增殖 | ||
|
|
||
| > "More tools don't always lead to better outcomes." | ||
|
|
||
| > "Too many tools or overlapping tools can also distract agents from pursuing efficient strategies." | ||
|
|
||
| **反面案例**:为每个 API 端点创建独立工具(`list_users`、`list_events`、`create_event`)。 | ||
|
|
||
| **推荐做法**:合并为任务导向的高阶工具(`schedule_event` 一个工具封装多个 API 调用)。 | ||
|
|
||
| ``` | ||
| ✗ 工具增殖(7 个低阶工具) ✓ 工具合并(2 个高阶工具) | ||
| ├── get_customer_by_id ├── get_customer_context | ||
| ├── list_transactions │ └── 内部调用 3 个 API | ||
| ├── list_notes └── search_logs | ||
| ├── read_logs └── 内部过滤+分页 | ||
| ├── filter_logs | ||
| ├── get_customer_details | ||
| └── get_customer_history | ||
| ``` | ||
|
|
||
| ### 命名空间策略 | ||
|
|
||
| > "For example, namespacing tools by service (e.g., `asana_search`, `jira_search`) and by resource (e.g., `asana_projects_search`, `asana_users_search`), can help agents select the right tools at the right time." | ||
|
|
||
| **命名前缀 vs 后缀的选择会影响模型性能**: | ||
|
|
||
| > "We have found selecting between prefix- and suffix-based namespacing to have non-trivial effects on our tool-use evaluations." | ||
|
|
||
| | 命名方式 | 示例 | 适用场景 | | ||
| |---------|------|---------| | ||
| | 服务前缀 | `github_create_issue` | 同一服务多操作 | | ||
| | 资源前缀 | `issues_create`、`issues_list` | 围绕资源 CRUD | | ||
| | 动作前缀 | `search_github`、`search_jira` | 跨服务同类操作 | | ||
|
|
||
| ### 描述即 Prompt 工程 | ||
|
|
||
| 工具描述的微小改动会导致 Agent 行为的显著变化: | ||
|
|
||
| - 返回**高信号语义信息**(项目名称),而非低信号技术标识(UUID) | ||
| - 实现分页、过滤和截断,附带有意义的错误消息 | ||
| - 用 2-3 个代表性示例替代穷举所有边界情况 | ||
|
|
||
| ### 对 SKILL.md / MCP 设计的实际指导 | ||
|
|
||
| | 场景 | 工具增殖 | 工具合并 | | ||
| |------|---------|---------| | ||
| | MCP 服务器设计 | 每个 API 端点一个 MCP 工具 | 按任务合并,一个工具封装多步 | | ||
| | SKILL.md 设计 | 每个子任务一个 Skill | 一个 Skill 编排完整工作流 | | ||
| | Hook 设计 | 每个检查一个 Hook | 一个 Hook 脚本执行多项检查 | | ||
|
|
||
| > **与 MCP 的关系**:Anthropic 指出 "The Model Context Protocol (MCP) can empower LLM agents with potentially hundreds of tools to solve real-world tasks."——但工具数量多不等于质量高。合并和命名空间策略对 MCP 工具同样适用。关于 MCP 命名约定(双下划线 vs 单下划线)对各 Agent 工具选择的具体影响,参见 [MCP 集成深度对比](../comparison/mcp-integration-deep-dive.md)中的「MCP 命名约定与模型工具选择」章节。 | ||
|
|
||
| --- | ||
|
|
||
| ## 相关资源 | ||
|
|
||
| ### 扩展开发 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 与
build-your-own-agent.md严重内容重复。 两个文件分别添加了来自同一篇 Anthropic 博客 (Writing Tools for Agents) 的几乎相同内容:三对子章节引用了完全相同的原文引句,核心论点 ~70% 相同。本文件多了 MCP 命名约定对比表(有价值),
build-your-own-agent.md多了 ASCII 目录树和 Hook/SKILL.md 对照表。建议:选择一处作为主章节完整展开,另一处仅用一句话概述 + 链接到主章节。例如在
build-your-own-agent.md中保留完整内容,在mcp-integration-deep-dive.md中仅保留 MCP 命名约定对比表(这是该文件独有的价值),其余用引用替代。Qwen-Code + GLM-5.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个重复问题完全成立。两个文件确实对同一篇博客做了 ~70% 相同的展开。
已采纳你的建议:
build-your-own-agent.md:保留完整的工具设计原则内容(合并/命名空间/描述优化)mcp-integration-deep-dive.md:精简为一句话概述 + 链接到主章节,仅保留 MCP 命名约定对比表(双下划线 vs 单下划线的歧义分析,这是 MCP 文件独有的价值)修改后
mcp-integration-deep-dive.md的工具设计章节从 ~45 行缩减到 ~20 行,消除了维护双份内容的负担。— Claude Opus 4.6