Skip to content

AgentCore Code Interpreter

A code execution feature provided by Amazon Bedrock AgentCore. AI can execute Python code in a sandboxed environment for data analysis, chart creation, file conversion, and more.

Files attached to a chat can be read and processed by Code Interpreter. Generated files (images, CSV, etc.) are displayed as download links in the chat interface.

Sessions are maintained within the same chat, so variables and files created in previous executions can be referenced in subsequent ones. The session timeout is 15 minutes.

Setup

1. Create an AgentCore Code Interpreter Resource

Create an AgentCore Code Interpreter resource using the AWS Management Console. An IAM role for the file I/O S3 folder must be created beforehand. Please contact support for details.

  1. Open the Amazon Bedrock AgentCore service page in the Tokyo region of the AWS Management Console
  2. Select Built-in tools > Code interpreter from the left menu
  3. Click the Create button
  4. Enter a tool name and configure the tool settings (sandbox is recommended for first-time setup)
  5. In the permissions settings, select the IAM role for S3 access created beforehand
  6. Click the Create button
  7. Open the created code interpreter and note the Code interpreter tool ID

2. S3 Bucket Permission

Files generated by AgentCore Code Interpreter are stored in S3 and can be downloaded from the chat interface. To enable downloads, S3 bucket access permissions must be configured. See S3 Bucket Access Permissions for details.

3. Configure the Assistant

  1. Open the assistant edit page in the admin console
  2. Select BedrockClaude as the Platform Metadata
  3. Enable AgentCore Code Interpreter Tool
  4. Enter the resource ID from step 1 in the Code Interpreter ID field
  5. Enable Adaptive Thinking, set Thinking Level to low and Max Tokens to 32000 (recommended)
  6. Adjust Max Tool Iterations as needed (default: 10)

For details on configuration fields, see Platform Metadata - BedrockClaude.