Skip to main content
AnthropicAdapter converts Anthropic computer actions to native desktop actions. It does not call the Anthropic API. Your application owns the model client, message history, policy, and limits.

Install the provider extra

Set ANTHROPIC_API_KEY in the application environment. Do not add the key to the Sandbox image.

Select a tool version

Use matching tool and beta versions. The adapter defaults to computer_20251124. Set enable_zoom=True to enable zoom for that version.

Declare the hosted tool

Anthropic owns the hosted computer tool schema. Do not add an input schema to it.
Keep the complete assistant content in message history. Continue only when stop_reason is tool_use. Return all matching tool results together in the next user message.

Execute actions in order

Create the adapter once for the complete loop:
Execute hosted tool calls in response order. Do not combine separate hosted calls into one batch.
Reuse a screenshot returned by screenshot or zoom. Return cursor coordinates as text. Capture one screenshot after another successful hosted action.

Use a batch tool only for fixed sequences

Your application can define a custom computer_batch tool. Use it only when every action can run without an intermediate model decision. All batch coordinates refer to the screenshot from before the batch. Execute actions sequentially. Stop on the first error. Use the hosted computer tool for these cases:
  • Exploratory navigation.
  • Sensitive steps.
  • Recovery after a failure.
  • A step that depends on an intermediate screen.

Supported actions

All versions support mouse movement, clicks, drag, key input, typing, screenshots, and cursor position. The 2025 versions also support scroll, mouse down and up, held keys, wait, and triple click. The computer_20251124 version supports zoom when you enable it. The adapter rejects an action that the selected version does not support.

Bound the loop

Set limits for turns, trajectory actions, batch actions, action time, and elapsed time. Stop before you act when the final allowed turn requests another tool call. Pass CoordinateSpace when the provider image size differs from the desktop size. The adapter then maps provider coordinates before execution.
Treat the task, page content, screenshots, provider output, typed text, and clipboard text as untrusted data. Require confirmation before an action creates an external effect. Anthropic’s hosted safety checks do not cover an application-owned batch tool.

Use the maintained example

Use the Anthropic loop example when your application needs a batch tool between model turns. It includes the reviewed schemas, message loop, limits, result handling, and cleanup. Your application still owns policy for hosted actions, the custom batch tool, provider output retention, and model cost.