Skip to content

Support Anthropic Code Execution 2026-01-20 tool (code_execution_20260120) #12794

@dflantz

Description

@dflantz

Description

Anthropic has released code_execution_20260120, the latest version of their code execution tool, which is now the recommended version for programmatic tool calling.

The AI SDK currently only supports code_execution_20250825 via anthropic.tools.codeExecution_20250825(). The newer version does not require a beta header and is supported on Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, and Opus 4.5.

What's needed

  1. A new anthropic.tools.codeExecution_20260120() factory (can reuse the 20250825 input/output schemas — they're the same)
  2. A case "anthropic.code_execution_20260120" in prepareTools (I didn't need a beta header in testing, but it may still be required?? Maybe anthropic is on the verge of GA)
  3. Tool name mapping entry: "anthropic.code_execution_20260120": "code_execution"
  4. Zod response schemas updated to accept "code_execution_20260120" as a valid caller.type (currently only "code_execution_20250825" | "direct")
  5. Runtime caller reconstruction in convertToAnthropicMessagesPrompt to handle the new caller type
  6. TypeScript type declarations for the new factory

Workaround

We're using patch-package to add all of the above to @ai-sdk/anthropic@3.0.46. Happy to open a PR if helpful.

Related

AI SDK Version

  • ai: 6.0.71
  • @ai-sdk/anthropic: 3.0.46

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelfeatureNew feature or requestprovider/anthropicIssues related to the @ai-sdk/anthropic providersupport

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions