Repolode
tjmlabs

tjmlabs/AgentRun

A Python library and REST API that runs LLM-generated Python code in an isolated Docker container with resource limits, timeouts, and safety checks.

Open-source alternative to:OpenAI Code Interpreter

Stars
383
Forks
39
Open issues
9
Last commit
15 days ago

What is it?

AgentRun lets an application hand Python code written by a large language model to a sandboxed environment and get back the output, including exceptions and tracebacks. It is built on the Docker Python SDK and RestrictedPython, and the code runs inside an isolated Docker container rather than on the host system.

Before execution, the code is checked for dangerous elements. Developers can control CPU quota, memory and swap limits, and execution timeouts (default 20 seconds), and can whitelist which pip packages may be installed. Dependencies can also be cached in advance in the container image to speed up later runs, and artifacts created by generated code are cleaned up automatically.

There are two ways to use it: install the pip package and attach it to your own running Docker container, or clone the repository and start the bundled Docker Compose setup, which exposes a REST endpoint at /v1/run/ for any language to call.

Key features

  • 01Checks generated code for dangerous operations before running it.
  • 02Runs code in an isolated Docker container.
  • 03Configurable CPU, memory, swap, and timeout limits.
  • 04Whitelisting and pre-caching of pip dependencies.
  • 05Ships with a ready-to-run Docker Compose REST API.
  • 06Returns the same output and tracebacks as running Python locally.

Use cases

  • Letting an LLM agent execute code to answer math or data questions.
  • Adding a code interpreter feature to a chatbot or AI product.
  • Self-hosting a sandboxed code execution service for internal tools.

Quick start

  1. 1

    Clone the GitHub repository

    git clone https://github.com/Jonathan-Adly/agentrun
  2. 2

    Enter the REST API folder

    cd agentrun/agentrun-api
  3. 3

    Create the environment file from the example

    cp .env.example .env.dev
  4. 4

    Build and start the Docker services

    docker-compose up -d --build

Things to know

  • Requires Docker to be installed and running.
  • The pip package needs you to supply your own running Docker container.

In collections

Topics

FAQ

What is AgentRun?
A Python library and REST API that runs LLM-generated Python code in an isolated Docker container with resource limits, timeouts, and safety checks. AgentRun lets an application hand Python code written by a large language model to a sandboxed environment and get back the output, including exceptions and tracebacks. It is built on the Docker Python SDK and RestrictedPython, and the code runs inside an isolated Docker container rather than on the host system.
Is AgentRun free to use? What license does it have?
AgentRun is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is AgentRun still maintained?
Actively maintained. The last commit to AgentRun was on Oct 23, 2026.
What can I use AgentRun for?
Letting an LLM agent execute code to answer math or data questions. Adding a code interpreter feature to a chatbot or AI product. Self-hosting a sandboxed code execution service for internal tools.
How do I install AgentRun?
Clone the GitHub repository: git clone https://github.com/Jonathan-Adly/agentrun Enter the REST API folder: cd agentrun/agentrun-api Create the environment file from the example: cp .env.example .env.dev Build and start the Docker services: docker-compose up -d --build
Where can I get AgentRun?
The source code and installation instructions are on GitHub: https://github.com/tjmlabs/AgentRun

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects