From 77357a6d50de3bea555c1d3676b5c28e10c34cce Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Thu, 27 Nov 2025 00:52:35 -0500 Subject: [PATCH] oss(py): document anthropic computer use --- .../python/integrations/chat/anthropic.mdx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/oss/python/integrations/chat/anthropic.mdx b/src/oss/python/integrations/chat/anthropic.mdx index f49b404e73..35b5baf4a2 100644 --- a/src/oss/python/integrations/chat/anthropic.mdx +++ b/src/oss/python/integrations/chat/anthropic.mdx @@ -1208,6 +1208,60 @@ I'd be happy to help you fix the syntax error in your primes.py file. First, let 'type': 'tool_call'}] ``` +### Computer use + +Claude supports [computer use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool) capabilities, allowing it to interact with desktop environments through screenshots, mouse control, and keyboard input. + + + **Important: You must provide the execution environment** + + LangChain handles the API integration (sending/receiving tool calls), but **you are responsible** for: + - Setting up a sandboxed computing environment (Linux VM, Docker container, etc.) + - Implementing a virtual display (e.g., Xvfb) + - Executing Claude's tool calls (screenshot, mouse clicks, keyboard input) + - Passing results back to Claude in an agent loop + + Anthropic provides a [reference implementation](https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo) to help you get started. + + + + **Requirements:** + + - Claude Opus 4.5, Claude 4, or Claude Sonnet 3.7 + + +```python +from langchain_anthropic import ChatAnthropic + +model = ChatAnthropic(model="claude-sonnet-4-5-20250929") + +# LangChain handles the API call and tool binding +computer_tool = { + "type": "computer_20250124", + "name": "computer", + "display_width_px": 1024, + "display_height_px": 768, + "display_number": 1, +} + +model_with_computer = model.bind_tools([computer_tool]) +response = model_with_computer.invoke( + "Take a screenshot to see what's on the screen" +) + +# response.tool_calls will contain the computer action Claude wants to perform +# You must execute this action in your environment and pass the result back +``` + + + **Available tool versions:** + + - `computer_20250124` (for Claude 4 and Claude Sonnet 3.7) + - `computer_20251124` (for Claude Opus 4.5) + + In each case, the required beta header is automatically added by LangChain when the tool is bound. + + --- ## API reference