Agent Sandbox Registry

awesome-templates

Sandbox runtime for the OpenAI Codex CLI…

无英文版

codex/README.md

codex

中文版 | English


English

Sandbox runtime for the OpenAI Codex CLI agent, supporting AI-driven code generation and execution.

Environment

This template comes preinstalled with the following tools and dependencies:

Category Details
Base image python:3.12-slim
Python Python 3 + venv (at /opt/venv)
Node.js Node.js 22.x + npm
Python packages openai>=1.0, rich, httpx
Node packages @openai/codex
System tools git, curl, wget, build-essential, ripgrep, jq
Resources 2 CPU / 4096 MB memory

Installation

Install from a local path:

abx template install ./codex --registry-type local

Install from GitHub:

abx template install alibaba-agent-sandbox/awesome-templates//codex

Usage

Create a sandbox instance and pass in the API key:

abx create --template codex --env OPENAI_API_KEY=sk-xxx

Run a code-generation task inside the sandbox:

abx exec <sandbox-id> -- codex "Write a quicksort algorithm"

Using the Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="codex",
    env={"OPENAI_API_KEY": "sk-xxx"}
)

result = sandbox.commands.run("codex 'Generate a Flask REST API'")
print(result.stdout)

Configuration

Environment Variables

Variable Description Required
OPENAI_API_KEY OpenAI API key Yes
CODEX_SANDBOX_MODE Sandbox mode marker, defaults to true No
WORKSPACE Working directory path, defaults to /workspace No

Custom Configuration

To install extra dependencies on top of this template, run the following after the sandbox is created:

abx exec <sandbox-id> -- pip install <package-name>
abx exec <sandbox-id> -- npm install -g <package-name>

Notes


中文

OpenAI Codex CLI Agent 的沙箱运行环境,支持 AI 驱动的代码生成和执行。

环境说明

本模板预装以下工具和依赖:

类别 内容
基础镜像 python:3.12-slim
Python Python 3 + venv 虚拟环境(位于 /opt/venv)
Node.js Node.js 22.x + npm
Python 包 openai>=1.0、rich、httpx
Node 包 @openai/codex
系统工具 git、curl、wget、build-essential、ripgrep、jq
资源配置 2 CPU / 4096 MB 内存

安装方式

从本地安装:

abx template install ./codex --registry-type local

从 GitHub 安装:

abx template install alibaba-agent-sandbox/awesome-templates//codex

使用示例

创建沙箱实例并传入 API Key:

abx create --template codex --env OPENAI_API_KEY=sk-xxx

在沙箱中执行代码生成任务:

abx exec <sandbox-id> -- codex "编写一个快速排序算法"

使用 Python SDK:

from agent_sandbox import Sandbox

sandbox = Sandbox.create_sync(
    template="codex",
    env={"OPENAI_API_KEY": "sk-xxx"}
)

result = sandbox.commands.run("codex '生成一个 Flask REST API'")
print(result.stdout)

配置说明

环境变量

变量名 说明 必填
OPENAI_API_KEY OpenAI API 密钥 是
CODEX_SANDBOX_MODE 沙箱模式标识,默认 true 否
WORKSPACE 工作目录路径,默认 /workspace 否

自定义配置

如需在模板基础上安装额外依赖,可在创建沙箱后执行:

abx exec <sandbox-id> -- pip install <package-name>
abx exec <sandbox-id> -- npm install -g <package-name>

注意事项

Deploy and local e2e

Install and register this template:

abx template install alibaba-agent-sandbox/awesome-templates//codex

From this directory (build, push, and register):

abx deploy

From the repository root, with agent-sandbox-server and httpx installed:

python3 scripts/run_local_e2e.py

That starts python3 commands.py in this directory and runs e2e_test.py.