Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/anthropic-computer-toolset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@tanstack/ai-anthropic': minor
---

Run computer use on every Claude model that supports it.

- `computerUseTool()` takes `computer_toolset_20260801`, the only computer use version of Claude Opus 5.5, Sonnet 5.5, and Haiku 5.5. The model calls each action as its own tool. The adapter runs each call as one `computer` call with the action in `input.action`, and sends it back to Claude in the form that Claude sent. So one `execute` works for every version.
- `computerUseTool()` takes `computer_20251124`, with its `computer-use-2025-11-24` beta header.
- Each model now takes only the computer use versions that it supports. For example, `computer_20250124` on `claude-opus-4-6` is a type error, because Anthropic rejects that pair.
- `@anthropic-ai/sdk` is now `^0.135.0`.
82 changes: 68 additions & 14 deletions docs/adapters/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,30 +618,84 @@ equivalent — see [Provider Skills](../tools/provider-skills.md).

### `computerUseTool`

Allows Claude to observe a virtual desktop (screenshots) and interact with it
via keyboard and mouse events. Provide the screen resolution so Claude can
calculate accurate coordinates.
Claude can look at a screen and use the mouse and the keyboard. Your app owns the screen: it runs each action that Claude asks for and sends back a screenshot.

1. Pick the version that your model takes:

| Version | Models |
| --- | --- |
| `computer_toolset_20260801` | Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1, Fable 5, Opus 5, Sonnet 5, Opus 4.8 |
| `computer_20251124` | Claude Fable 5.1, Fable 5, Opus 5, Sonnet 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 4.6, Opus 4.5 |
| `computer_20250124` | Claude Sonnet 4.5, Haiku 4.5, Opus 4.1 |

2. Give the tool an `execute` that runs each action on your screen.
3. Return a screenshot for the `screenshot` action, and `"OK"` for the other actions.

```typescript
import { chat } from "@tanstack/ai";
import { anthropicText } from "@tanstack/ai-anthropic";
import { computerUseTool } from "@tanstack/ai-anthropic/tools";

// Your screen, for example a virtual machine. Replace these two functions.
async function runAction(input: { action: string }): Promise<void> {
console.log("run", input);
}
async function takeScreenshot(): Promise<string> {
return ""; // A PNG, as base64.
}

const computer = {
...computerUseTool({
type: "computer_toolset_20260801",
configs: { zoom: { enabled: false } },
}),
// Every version calls `execute` with the action in `input.action`.
execute: async (input: { action: string }) => {
if (input.action === "screenshot") {
const value = await takeScreenshot();
return [
{
type: "image",
source: { type: "data", value, mimeType: "image/png" },
},
];
}
await runAction(input);
return "OK";
},
};

const stream = chat({
adapter: anthropicText("claude-sonnet-4-6"),
messages: [{ role: "user", content: "Open the browser and go to example.com" }],
tools: [
computerUseTool({
type: "computer_20250124",
name: "computer",
display_width_px: 1024,
display_height_px: 768,
}),
],
adapter: anthropicText("claude-opus-5-5"),
messages: [{ role: "user", content: "Open the display settings." }],
tools: [computer],
// Claude can ask for several actions in one turn. Run them in order.
toolExecution: "sequential",
});
```

**Supported models:** Claude Sonnet 3.5 and above, with two exceptions. `claude-opus-5-fast` takes no provider tools. Claude Opus 5.5, Claude Sonnet 5.5, and Claude Haiku 5.5 accept only the `computer_toolset_20260801` toolset, which the adapter does not offer yet. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).
The earlier versions also take a name and the screen size:

```typescript
import { computerUseTool } from "@tanstack/ai-anthropic/tools";

const computer = computerUseTool({
type: "computer_20251124",
name: "computer",
display_width_px: 1280,
display_height_px: 800,
});
```

Good to know:

- The adapter sends the beta header that an earlier version needs. The toolset needs no beta header.
- With the toolset, Claude calls each action as its own tool. The adapter gives you each call as one `computer` call, and sends it back in the form that Claude sent. So one `execute` works for every version.
- The toolset turns on `zoom` by default. To let Claude zoom, remove `configs` and return an image for the `zoom` action too.
- Send screenshots that fit the image limits of the model. The toolset does not make a large screenshot smaller. It refuses it. Claude gives coordinates in the pixels of your screenshots.
- If an action fails, answer each later action of the same turn with `Not executed: an earlier computer action in this turn failed.`

A version that your model does not take is a type error. `claude-opus-5-fast` takes no provider tools. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).

### `bashTool`

Expand Down
4 changes: 2 additions & 2 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
"label": "Provider Tools",
"to": "tools/provider-tools",
"addedAt": "2026-04-21",
"updatedAt": "2026-09-24"
"updatedAt": "2026-10-19"
},
{
"label": "Provider Skills",
Expand Down Expand Up @@ -1215,7 +1215,7 @@
"label": "Anthropic",
"to": "adapters/anthropic",
"addedAt": "2026-04-15",
"updatedAt": "2026-10-09"
"updatedAt": "2026-10-19"
},
{
"label": "Google Gemini",
Expand Down
8 changes: 4 additions & 4 deletions docs/tools/provider-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ Each adapter's `supports.tools` array is the source of truth. The comparison
matrix is maintained alongside `model-meta.ts` and reflected here:

- **Anthropic**: every registered model supports the full tool superset,
except four. `claude-opus-5-5`, `claude-sonnet-5-5`, and
`claude-haiku-5-5` support every tool but `computerUseTool`, and
`claude-opus-5-fast` supports none. The
retired Claude 3.x models with narrower support were removed.
except `claude-opus-5-fast`, which supports none. For `computerUseTool`,
each model takes only some versions. The Claude 5.5 models take only
`computer_toolset_20260801`. See the version table in
[`computerUseTool`](../adapters/anthropic.md#computerusetool).
- **OpenAI**: GPT-5 family and reasoning models (O-series) support the full
superset. GPT-6 Astra, Sol, and Luna support every tool except
`webSearchPreviewTool` and `localShellTool`. GPT-4-series supports
Expand Down
2 changes: 1 addition & 1 deletion examples/ts-react-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:types": "tsc --noEmit"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.97.1",
"@anthropic-ai/sdk": "^0.135.0",
"@elevenlabs/elevenlabs-js": "^2.68.0",
"@mcp-ui/client": "^7.1.1",
"@modelcontextprotocol/sdk": "^1.29.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/ai-anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"test:types": "tsc"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.97.1",
"@anthropic-ai/sdk": "^0.135.0",
"@tanstack/ai-utils": "workspace:^"
},
"peerDependencies": {
Expand All @@ -80,7 +80,6 @@
}
},
"devDependencies": {
"@anthropic-ai/sdk-v112": "npm:@anthropic-ai/sdk@0.112.4",
"@anthropic-ai/vertex-sdk": "^0.19.0",
"@tanstack/ai": "workspace:*",
"@vitest/coverage-v8": "4.1.10",
Expand Down
4 changes: 2 additions & 2 deletions packages/ai-anthropic/src/adapters/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getAnthropicCredentialFromEnv,
} from '../utils/client'
import type Anthropic_SDK from '@anthropic-ai/sdk'
import type { FileMetadata } from '@anthropic-ai/sdk/resources/beta/files'
import type { BetaFileMetadata } from '@anthropic-ai/sdk/resources/beta/files'
import type { FileHandle, FileUploadInput } from '@tanstack/ai/adapters'
import type { AnthropicClientConfig } from '../utils/client'

Expand Down Expand Up @@ -55,7 +55,7 @@ export class AnthropicFilesAdapter extends BaseFilesAdapter<'anthropic'> {
}
}

function toFileHandle(file: FileMetadata): FileHandle<'anthropic'> {
function toFileHandle(file: BetaFileMetadata): FileHandle<'anthropic'> {
return {
id: file.id,
provider: 'anthropic',
Expand Down
Loading
Loading