Documentation Index
Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-mdrxyo-1777658790-7be347c.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Amazon Bedrock AgentCore Code Interpreter is a sandbox backend for Deep Agents, enabling secure code execution in isolated MicroVM environments.
Installation
pip install langchain-agentcore-codeinterpreter
Create a sandbox backend
See the sandboxes guide for usage, file operations, and lifecycle details.
from bedrock_agentcore.tools.code_interpreter_client import CodeInterpreter
from langchain_agentcore_codeinterpreter import AgentCoreSandbox
interpreter = CodeInterpreter(region="us-west-2")
interpreter.start()
backend = AgentCoreSandbox(interpreter=interpreter)
result = backend.execute("echo hello")
print(result.output)
interpreter.stop()
Use with Deep Agents
from bedrock_agentcore.tools.code_interpreter_client import CodeInterpreter
from langchain_agentcore_codeinterpreter import AgentCoreSandbox
from langchain_anthropic import ChatAnthropic
from deepagents import create_deep_agent
interpreter = CodeInterpreter(region="us-west-2")
interpreter.start()
backend = AgentCoreSandbox(interpreter=interpreter)
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-20250514"),
system_prompt="You are a coding assistant with sandbox access.",
backend=backend,
)
try:
result = agent.invoke(
{"messages": [{"role": "user", "content": "Write and run a Python script"}]}
)
finally:
interpreter.stop()
Cleanup
Always stop the interpreter when you are done to release resources.
See also: Sandboxes.