Skip to content

feat(provider/anthropic): add code_execution_20250825 tool#9435

Merged
lgrammel merged 38 commits intovercel:mainfrom
ellisgouller:feat/anthropic-code-execution-20250825
Oct 14, 2025
Merged

feat(provider/anthropic): add code_execution_20250825 tool#9435
lgrammel merged 38 commits intovercel:mainfrom
ellisgouller:feat/anthropic-code-execution-20250825

Conversation

@ellisgouller
Copy link
Copy Markdown
Contributor

@ellisgouller ellisgouller commented Oct 13, 2025

Background

Anthropic has released a new tool code_execution_20250825.

Summary

Added Anthropic code execution tool 20250825 with enhanced bash and text editing support.

Manual Verification

  • ran pnpm tsx src/generate-text/anthropic-code-execution-latest.ts and confirmed the tool worked.
  • ran pnpm tsx src/stream-text/anthropic-code-execution-latest.ts and confirmed the tool worked.
  • test ui example http://localhost:3000/chat-anthropic-code-execution with multiple messages

Tasks

  • add snapshot test generate
  • add snapshot test stream
  • map tool calls and call streaming to code execution tool
  • remove output camelcase mapping
  • create and test e2e ui example
  • multi-turn / input mapping
  • figure out text editor input schemas for str_replace and view

Future Work

  • Anthropic file id support

Related Issues

closes #9433

…enhanced Bash support and add new result types for text editor and Bash execution
@ellisgouller
Copy link
Copy Markdown
Contributor Author

to close issue #9433

Comment thread packages/anthropic/src/convert-to-anthropic-messages-prompt.ts
@ellisgouller
Copy link
Copy Markdown
Contributor Author

@gr2m this is my first PR on this repo, can I get some feedback & tips on anything I can do to get things merged quicker?

Comment thread package.json Outdated
Comment thread packages/anthropic/src/convert-to-anthropic-messages-prompt.ts
@lgrammel
Copy link
Copy Markdown
Collaborator

@ellispinsky I'll take it from here, thanks for the pr.

@lgrammel lgrammel changed the title feat(anthropic): update code execution tool to version 20250825 with … feat(provider/anthropic): add code_execution_20250825 tool Oct 14, 2025
@lgrammel
Copy link
Copy Markdown
Collaborator

needs to support new fields
image

@lgrammel
Copy link
Copy Markdown
Collaborator

lgrammel commented Oct 14, 2025

This is way more complex. The tool input/output processing needs to be rewritten and we need to distinguish between the old and the new tool version.

@lgrammel
Copy link
Copy Markdown
Collaborator

more changes planned, pls do not make any commits

Comment thread packages/anthropic/src/anthropic-messages-language-model.ts
@lgrammel lgrammel added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Oct 14, 2025
@lgrammel lgrammel self-assigned this Oct 14, 2025
@lgrammel lgrammel merged commit 6f845b4 into vercel:main Oct 14, 2025
17 of 18 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Oct 14, 2025
@vercel-ai-sdk vercel-ai-sdk bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Oct 14, 2025
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Oct 14, 2025

⚠️ Backport to release-v5.0 created but has conflicts: #9491

lgrammel added a commit that referenced this pull request Oct 14, 2025
…9491)

This is an automated backport of #9435 to the release-v5.0 branch.

---------

Co-authored-by: ellispinsky <48781372+ellispinsky@users.noreply.github.com>
Co-authored-by: Lars Grammel <lars.grammel@gmail.com>
lgrammel added a commit that referenced this pull request Oct 23, 2025
… code-execution-20250825 to download output files (#9669)

## Background

The Anthropic code execution bash tool provides a list of the generated
files. This feature was missing from #9435 (although present in the zod
schemas). It enables downloading generated files from the Anthropic API.

## Summary

- add response property `file_id `in code-execution-20250825
- add example downloading file.

## Example

Use code execution to have the AI ​​create an Excel file. Get the
executed python code.

![anthropic_code_execution_file_download](https://github.com/user-attachments/assets/840eee84-2cf8-4710-8ba3-a03824c3fe04)

prompt:

`Write a Python script to calculate fibonacci number and then execute it
to find the 10th fibonacci number finally output data to excel file and
python code.`

## Manual Verification

### package/anthropic
- packages/anthropic/src/anthropic-messages-language-model.test.ts
- add fixtures `anthropic-code-execution-20250825.2` for file_id return
pattern.
  - check the snapshot and file_id was included in the result.

### examples/ai-core
- add the examples,
src/stream-text/anthropic-code-execution-20250825-downloads.ts
- add the examples,
src/generate-text/anthropic-code-execution-20250825-downloads.ts

### examples/next-openai
- fix /components/tool/anthropic-code-execution-view.tsx (add a download
button)
- add route for submit native download api and provide files.
/app/api/code-execution-files/anthropic/[file]/route.ts

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the
project root)
- [x] I have reviewed this pull request (self-review)

## Related Issues

Fixes gap from #9435

---------

Co-authored-by: tsuzaki430 <tsuzaki430@users.noreply.github.com>
Co-authored-by: Lars Grammel <lars.grammel@gmail.com>
@gr2m gr2m added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/anthropic Issues related to the @ai-sdk/anthropic provider labels Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/anthropic Issues related to the @ai-sdk/anthropic provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Anthropic Code Execution 2025-08-25 tool

3 participants