Loading...
  • 构建
  • 管理
  • 模型与定价
  • 客户端 SDK
  • API 参考
Search...
⌘K
Log in
工具组合
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Amazon Bedrock
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
构建/工具基础设施

工具组合

用于研究代理、编码代理和长期运行代理的常见 Anthropic 工具配对。

Anthropic 提供的工具设计用于协同工作。常见的代理模式将涵盖工作流互补阶段的工具配对在一起:一个工具用于收集或发现,另一个工具用于处理或执行。下面的组合是起点,而不是规定。根据您的任务混合搭配它们。

每个代码片段仅显示 tools 数组。有关完整的请求形状,请参阅处理工具调用。

研究代理:web_search + code_execution

搜索查找来源;代码执行分析和综合。Claude 搜索数据,然后编写 Python 来处理、制表或可视化数据。这种配对非常适合需要最新信息和对该信息进行非平凡计算的问题,例如"比较前五大云提供商的本季度收益"。

{
  "tools": [
    { "type": "web_search_20260209", "name": "web_search" },
    { "type": "code_execution_20250825", "name": "code_execution" }
  ]
}

流程通常是搜索,然后执行,如果第一次通过发现了差距,则可选地再次搜索。代码执行在服务器端运行,因此没有客户端沙箱需要管理。

编码代理:text_editor + bash

文本编辑器读取和修改文件;bash 运行测试和构建命令。这是规范的软件开发循环:检查代码、进行编辑、运行测试、重复。两个工具都是客户端执行的,因此您的应用程序控制哪些文件和命令可访问。

{
  "tools": [
    { "type": "text_editor_20250728", "name": "str_replace_based_edit_tool" },
    { "type": "bash_20250124", "name": "bash" }
  ]
}

如果代理在不受信任的代码上运行,请将其与受限的工作目录和命令允许列表配对。有关执行合约,请参阅文本编辑器工具和 Bash 工具。

引用后获取:web_search + web_fetch

搜索显示候选 URL;获取检索相关 URL 的完整页面内容。这避免了预先获取所有内容。Claude 运行搜索、检查片段、选择看起来实际相关的两三个结果,并仅获取那些结果。

{
  "tools": [
    { "type": "web_search_20260209", "name": "web_search" },
    { "type": "web_fetch_20260209", "name": "web_fetch" }
  ]
}

当答案位于长篇内容(文档页面、文章、规范)中时,此配对很有用,搜索片段无法完全捕获这些内容。获取会拉取完整页面,以便 Claude 可以引用特定段落。

长期运行代理:memory + 任何工具集

内存在对话中保持状态;其他工具执行工作。将内存添加到任何需要记住先前会话的代理,例如回忆客户早期问题的支持代理或跟踪上周做出的决定的项目助手。

{
  "tools": [{ "type": "memory_20250818", "name": "memory" }]
}

在同一数组中将您的其他工具与 memory 一起添加。

内存与您的其余工具集正交。它不会改变其他工具的行为方式;它为 Claude 提供了一个地方来记录和稍后检索事实,否则这些事实在上下文窗口重置时会丢失。有关存储模型,请参阅内存工具。

一体化:computer_use

计算机使用工具通过操作完整桌面来包含大多数其他工具。Claude 看到屏幕截图并发出鼠标和键盘操作,这意味着它可以驱动人类可以驱动的任何应用程序。当任务需要更具体的工具无法达到的任意 GUI 交互时,请使用此工具:没有 API 的遗留软件、视觉验证步骤或跨多个桌面应用程序的工作流。

{
  "tools": [
    {
      "type": "computer_20250124",
      "name": "computer",
      "display_width_px": 1280,
      "display_height_px": 800
    }
  ]
}

计算机使用是最通用的选项,也是最慢的,因为每个操作都需要屏幕截图往返。当更窄的工具涵盖您的用例时,更倾向于使用它们,当没有其他工具适合时,使用计算机使用。有关沙箱设置,请参阅计算机使用工具。

后续步骤

工具参考

Anthropic 提供的工具的完整目录,包含类型字符串和参数。

工具使用概述

工具使用的工作原理以及何时使用 Anthropic 工具与定义自己的工具。

Was this page helpful?

  • 研究代理:web_search + code_execution
  • 编码代理:text_editor + bash
  • 引用后获取:web_search + web_fetch
  • 长期运行代理:memory + 任何工具集
  • 一体化:computer_use