Skip to content

fix(code-interpreter): add blob support to write_files for binary file uploads#462

Open
rogep wants to merge 2 commits intostrands-agents:mainfrom
rogep:feature/code-interpreter-file-write-support-bytes
Open

fix(code-interpreter): add blob support to write_files for binary file uploads#462
rogep wants to merge 2 commits intostrands-agents:mainfrom
rogep:feature/code-interpreter-file-write-support-bytes

Conversation

@rogep
Copy link
Copy Markdown

@rogep rogep commented Apr 30, 2026

fix(code-interpreter): add blob support to write_files for binary file uploads

Description

write_files currently only passes text to the BedrockAgentCore SDK,
silently dropping any blob field. This means binary files (images,
compiled artifacts, etc.) cannot be written to the sandbox, but the SDK
supports blob on writeFiles but the tool never forwarded it.

Changes:

  • Added blob: Optional[str] field to FileContent model with a
    model_validator enforcing that exactly one of text or blob is set
  • Updated write_files in AgentCoreCodeInterpreter to forward blob
    to the SDK when present, falling back to text

Discovered this gap while using the tool in production to write binary
files to a sandbox session. The BedrockAgentCore SDK already supports
blob on writeFiles (see SDK source), but the strands tool just
wasn't surfacing it.

Related Issues

Fixes #304

Documentation PR

N/A

Type of Change

Bug fix

Testing

Added a test covering a mixed content list with both text and blob
entries flowing through the tool dispatch.

Verified that the BedrockAgentCore SDK already supports blob on
writeFiles: https://github.com/aws/bedrock-agentcore-sdk-python/blob/main/src/bedrock_agentcore/tools/code_interpreter_client.py#L516

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy,
and redistribute this contribution, under the terms of your choice.

@rogep rogep requested a deployment to manual-approval April 30, 2026 03:28 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add binary blob support to FileContent for code_interpreter tool

1 participant