feat: Add `files` support to `CodeExecutionTool` for Anthropic and OpenAI
Merged
HE
5mo ago+3698+3698+0123456789012345678901234567890123456789-8-8-0123456789
Summary
- Add
file_idsparameter toCodeExecutionToolto allow uploading files to code execution containers - Upgrade Anthropic CodeExecutionTool from
code_execution_20250522tocode_execution_20250825beta - Add OpenAI Responses API support for
file_idsin code_interpreter container - Support both providers as required by maintainer feedback for new generic class fields
Changes
Anthropic
- Upgrade to
code-execution-2025-08-25beta which supports file uploads - Add
container_uploadblocks to user messages whenfile_idsare provided - Automatically enable
files-api-2025-04-14beta when file_ids are used - Handle new result block types:
BetaBashCodeExecutionToolResultBlock,BetaTextEditorCodeExecutionToolResultBlock
OpenAI
- Pass
file_idstocode_interpretercontainer configuration - Extract
_map_mcp_server_toolhelper to reduce function complexity
Documentation
- Add "File Uploads" section with examples for both Anthropic and OpenAI
- Update provider support table to show ✅ for both providers
Test plan
-
Unit tests for Anthropic file_ids with and without files
-
Unit tests for OpenAI file_ids with and without files
-
End-to-end test with OpenAI (verified file upload and code execution works)
-
All existing tests pass
-
Type checking passes
-
Linting passes
-
Closes #4319
Pre-Review Checklist
- Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
- No breaking changes in accordance with the version policy.
- Linting and type checking pass per
make formatandmake typecheck. - PR title is fit for the release changelog.
Pre-Merge Checklist
- New tests for any fix or new behavior, maintaining 100% coverage.
- Updated documentation for new features and behaviors, including docstrings for API docs.