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"]
在每個步驟之後,截取屏幕截圖並仔細評估您是否已經達到了正確的結果。明確展示您的思考過程:"我已經評估了步驟 X..."如果不正確,請重試。只有當您確認步驟已正確執行時,才能繼續下一步。
<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
預算。