Skip to main content
Your application owns the Anthropic client, message history, limits, and approval policy. AnthropicAdapter only converts provider actions to SDK actions.

Install the provider extra

Store ANTHROPIC_API_KEY in the placed Function. Keep it out of the desktop Sandbox.

Select matching tool versions

The adapter defaults to computer_20251124. Set enable_zoom=True when you want zoom with that version.

Keep the loop inside the placed Function

Follow the session handoff guide. Borrow once around the complete Messages API loop.
Keep the complete assistant content in message history. Continue only when stop_reason is tool_use. Return all matching tool results in the next user message.

Preserve hosted-tool order

Execute hosted computer calls in response order. Use computer.step() for actions that need an immediate screenshot.
Keep these provider semantics:
  • Return cursor coordinates as text for cursor_position.
  • Reuse the native image from screenshot or zoom when present.
  • Avoid a duplicate trailing image after a native image action.
  • Keep separate hosted calls separate.
Use a custom batch tool only for a fixed sequence that needs no intermediate model decision. Send its ordered actions in one computer.step() call.

Use the maintained example

The Anthropic loop example contains reviewed schemas, the placed Function, provider ordering, batch handling, limits, result conversion, cancellation, and cleanup.
Treat tasks, page content, screenshots, provider output, typed text, and clipboard text as untrusted. Ask for approval before an action creates an external effect. Anthropic safety checks do not cover an application-owned batch tool.