Skip to main content
Amazon Bedrock AgentCore Code Interpreter enables agents to execute code in secure, managed sandbox environments. Agents can run Python, JavaScript, and TypeScript code for calculations, data analysis, file manipulation, and visualizations.

Overview

Integration details

Tool features

Available tools

The toolkit provides multiple tools for code execution and file management:

Setup

The integration lives in the langchain-aws package, which wraps the bedrock-agentcore SDK.

Credentials

You need AWS credentials configured with permissions for Bedrock AgentCore Code Interpreter. See the Amazon Bedrock AgentCore documentation for required IAM permissions. It’s also helpful (but not needed) to set up LangSmith for best-in-class observability:

Instantiation

The toolkit is created using an async factory function:

Invocation

Direct tool usage

Get specific tools and invoke them:

Use within an agent

Thread-based session isolation

The toolkit supports multiple concurrent sessions via thread_id. Each thread maintains its own code interpreter session with isolated state:

Working with files

Write and read files

Upload files with descriptions

Installing packages

Async task management

For long-running commands, you can start them asynchronously and check their status:

Session cleanup

Always clean up sessions when done to release resources:

API reference

For detailed documentation of all features and configurations, see: