Bearly Code Interpreter Tool
Guide for using the Bearly Code Interpreter tool with PraisonAI agents.
The Bearly Code Interpreter tool lets an agent run code in a sandboxed cloud environment.
graph LR
subgraph "Bearly Code Interpreter"
User[User] --> Agent[Agent]
Agent --> Tool[BearlyInterpreterTool]
Tool --> API[Bearly Sandbox]
API --> Result[Output]
end
classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
classDef output fill:#10B981,stroke:#7C90A0,color:#fff
class User,Agent input
class Tool,API process
class Result outputOverview
The Bearly Code Interpreter tool is a tool that allows you to execute various programming languages using the AI Agents.
pip install langchain-community
export BEARLY_API_KEY="${BEARLY_API_KEY:?Set BEARLY_API_KEY in your shell}"from praisonaiagents import Agent, AgentTeam
from langchain_community.tools import BearlyInterpreterTool
coder_agent = Agent(instructions="""for i in range(0,10):
print(f'The number is {i}')""", tools=[BearlyInterpreterTool])
agents = AgentTeam(agents=[coder_agent])
agents.start()How It Works
sequenceDiagram
participant User
participant Agent
participant Bearly as BearlyInterpreterTool
participant API as Bearly Sandbox
User->>Agent: "Run this code"
Agent->>Bearly: execute(code)
Bearly->>API: run in sandbox
API-->>Bearly: stdout / result
Bearly-->>Agent: output
Agent-->>User: final answerGetting Started
- Simple Usage
- Install dependencies (see Overview above)
- Set required API keys in your environment
- Run the agent example in Overview
- With Configuration
Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.
Best Practices
Keep BEARLY_API_KEY in the environment
Set BEARLY_API_KEY in your shell or .env. The tool reads it automatically — never hard-code the key.
Sandbox untrusted code
Bearly runs code in an isolated cloud sandbox, so agent-generated code cannot touch your machine. Prefer it over local execution for untrusted input.
Keep snippets self-contained
Each run is stateless. Include all imports and inputs in the snippet you pass so it executes without external state.