← Directory

AgentRun

Open Source
• Updated Jun 4, 2026, 07:14 PM

AgentRun is an open-source Python library designed for safely executing AI-generated Python code.

Use Cases ▼
01

Running code generated by AI coding assistants (like GitHub Copilot or ChatGPT) in a safe environment.

02

Building autonomous AI agents that can execute Python code as part of a reasoning loop, with protection against unintended side effects.

03

Educational platforms where students can submit Python code that is executed securely without risking server integrity.

04

Prototyping and testing LLM-generated scripts for data analysis or automation without manual review.

05

Implementing a secure code interpreter for chatbots that allows users to run Python calculations or visualizations.

What Problem It Solves ▼

AI-generated code poses significant security risks because it can contain malicious instructions, infinite loops, or resource exhaustion attacks. Developers integrating LLMs into applications need a way to execute model outputs safely without endangering the host system. AgentRun solves this by providing a lightweight sandboxed execution environment that restricts the capabilities of untrusted code, allowing safe and controlled execution.

Key Features ▼
✓

Easy to integrate with existing Python codebases via a simple API.

✓

Strong security with multiple isolation backends (native or Docker).

✓

Configurable resource limits prevent denial-of-service attacks.

✓

Open source and actively maintained with frequent updates.

✓

Supports both local and remote execution through optional API server.

Overview

AgentRun is an open-source Python library designed for safely executing AI-generated Python code. It addresses the security risks associated with running arbitrary code produced by large language models (LLMs) or other AI systems. By providing a sandboxed execution environment, AgentRun ensures that malicious or unintentionally harmful code cannot compromise the host system.

Full Description ▼

Key features include configurable resource limits (CPU, memory, timeouts), optional network isolation, and filesystem restrictions. It supports different isolation backends, such as native operating system-level sandboxing (e.g., seccomp, namespaces) and Docker containers for enhanced security. The library integrates seamlessly with AI agent frameworks, allowing developers to execute model outputs without manual review.

AgentRun is designed for ease of use, with a simple API that mirrors Python's built-in exec() function but with safety boundaries. It also provides an optional API server (agentrun-api) for remote code execution services, enabling deployment in distributed systems. Comprehensive monitoring and logging capabilities allow tracking of executed code, resource usage, and potential security events.

The project is actively maintained on GitHub, with extensive documentation and a test suite. It is distributed via PyPI for easy installation. AgentRun is suitable for both local development and production environments, empowering developers to build AI-powered applications that interact with user-provided or generated code safely.

Pros & Cons

Pros

+

Easy to integrate with existing Python codebases via a simple API.

+

Strong security with multiple isolation backends (native or Docker).

+

Configurable resource limits prevent denial-of-service attacks.

+

Open source and actively maintained with frequent updates.

+

Supports both local and remote execution through optional API server.

Cons

−

Sandboxing may not be fully bulletproof against kernel-level exploits.

−

Limited to Python code execution; other languages not supported.

−

Docker-based isolation adds overhead and requires Docker installation.

Similar Tools

E2B CodeSandbox Firejail gVisor sandboxctl

More in AI Agents