1. 向 Claude 提供电脑使用工具和用户提示
2. Claude 决定使用工具
stop_reason
为 tool_use
,表示 Claude 的意图。3. 提取工具输入,在计算机上评估工具,并返回结果
tool_result
内容块的新 user
消息。4. Claude 继续调用电脑使用工具,直到完成任务
tool_use
stop_reason
,您应该返回步骤 3。Claude 4 测试版标志
20250429
的工具(Claude 4 工具)时,
包含此测试版标志:"betas": ["computer-use-2025-01-24"]
Claude Sonnet 3.7 测试版标志
20250124
的工具(Claude Sonnet 3.7 工具)时,
包含此测试版标志:"betas": ["computer-use-2025-01-24"]
注意:
Bash(bash_20250124
)和文本编辑器(text_editor_20250124
)工具
也可用于 Claude Sonnet 3.5(新版),无需电脑使用测试版标头即可使用。Claude Sonnet 3.5(新版)测试版标志
20241022
的工具(Claude Sonnet 3.5 工具)时,
包含此测试版标志:"betas": ["computer-use-2024-10-22"]
<robot_credentials>
)提供用户名和密码。在需要登录的应用程序中使用电脑使用功能会增加因提示注入而导致不良结果的风险。在向模型提供登录凭据之前,请查看我们关于缓解提示注入的指南。您可以访问一组函数,用于回答用户的问题。这包括访问沙盒计算环境。除了调用以下函数外,您目前无法检查文件或与外部资源交互。与常规工具使用一样,用户提供的
system_prompt
字段仍然受到尊重,并用于构建组合系统提示。
description
和 tool_schema
字段。
tool_results
返回给 Claude。与任何工具一样,模型不会自动执行工具。Claude 4 工具
{ "type": "computer_20250124", "name": "computer" }
- 增强的计算机控制,精度更高{ "type": "text_editor_20250429", "name": "str_replace_based_edit_tool" }
- 更新的文本编辑器,没有 undo_edit
命令{ "type": "bash_20250124", "name": "bash" }
- 增强的 bash shell,功能更强大undo_edit
命令。在设计工作流程时请相应规划。Claude Sonnet 3.7 工具
{ "type": "computer_20250124", "name": "computer" }
- 包括用于更精确控制的新操作{ "type": "text_editor_20250124", "name": "str_replace_editor" }
- 与 20241022 版本相同的功能{ "type": "bash_20250124", "name": "bash" }
- 与 20241022 版本相同的功能Claude Sonnet 3.5(新版)工具
{ "type": "computer_20241022", "name": "computer" }
{ "type": "text_editor_20241022", "name": "str_replace_editor" }
{ "type": "bash_20241022", "name": "bash" }
type
字段标识工具及其验证参数,name
字段是暴露给模型的工具名称。
如果您想提示模型使用这些工具之一,可以通过 name
字段明确引用该工具。name
字段在工具列表中必须是唯一的;您不能在同一个 API 调用中定义与 Anthropic 定义的工具同名的工具。
tools
块中是唯一的),但这样做可能会导致模型性能下降。计算机工具
computer_20250124
- 具有高级功能的增强计算机工具,用于 Claude 4computer_20250124
- 增强计算机工具,在 Claude Sonnet 3.7 中提供额外操作computer_20241022
- 与 Claude Sonnet 3.5(新版)一起使用的原始计算机工具display_width_px
:必需 模型控制的显示器宽度(以像素为单位)。display_height_px
:必需 模型控制的显示器高度(以像素为单位)。display_number
:可选 要控制的显示器编号(仅与 X11 环境相关)。如果指定,工具定义中将提供显示器编号。computer_20250124
工具的完整输入模式:computer_20241022
工具:文本编辑器工具
thinking
参数:
budget_tokens
参数指定 Claude 可以用于思考的令牌数量。这将从您的总体 max_tokens
预算中扣除。
启用思考功能后,Claude 将在响应中返回其推理过程,这可以帮助您:
tool_use
结果的代理循环left_mouse_down
、left_mouse_up
)和新的修饰键支持得到了改进。通过使用这些细粒度控制并将修饰键与点击结合使用,单元格选择可以更可靠。模型 | 工具选择 | 系统提示令牌数 |
---|---|---|
Claude 4 Opus 和 Sonnet | auto any , tool | 466 令牌 499 令牌 |
Claude Sonnet 3.7 | auto any , tool | 466 令牌 499 令牌 |
Claude Sonnet 3.5(新版) | auto any , tool | 466 令牌 499 令牌 |
工具 | 额外输入令牌 |
---|---|
computer_20250124 (Claude 4) | 735 令牌 |
computer_20250124 (Claude Sonnet 3.7) | 735 令牌 |
computer_20241022 (Claude Sonnet 3.5) | 683 令牌 |
text_editor_20250429 (Claude 4) | 700 令牌 |
text_editor_20250124 (Claude Sonnet 3.7) | 700 令牌 |
text_editor_20241022 (Claude Sonnet 3.5) | 700 令牌 |
bash_20250124 (Claude 4) | 245 令牌 |
bash_20250124 (Claude Sonnet 3.7) | 245 令牌 |
bash_20241022 (Claude Sonnet 3.5) | 245 令牌 |
budget_tokens
计入您的 max_tokens
预算。