Skip to main content

Training & evals

Hugging Face OpenEnv

OpenEnv's Terminus environment runs terminal commands in E2B, so a policy can inspect, run and fix code over several turns. Get a first reward without a GPU.

Maintained by
E2B
How it works
Terminus environment runs on E2B
Environment
Terminus (OpenEnv 0.8.0)
Language
Python

Set it up

Get started

Paste the prompt into your coding agent, or follow the steps yourself.

Paste this into your coding agent

Add E2B sandboxes to this OpenEnv project.

  1. 1.Get the openenv-terminus-python example from the E2B cookbook and install its pinned dependencies with uv sync --frozen.
  2. 2.The example needs the E2B_API_KEY environment variable in its .env file. If it isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode it.
  3. 3.Follow the OpenEnv guide at https://docs.e2b.dev/agents/openenv: start the local Terminus server, then run episodes through ReportEpisode so each one resets into a fresh E2B sandbox and is graded on the host.
  4. 4.Run the demo once and show me the rewards and the report output that came from the sandbox.

Or set it up yourself

  1. 1. Get the Terminus example

    git clone https://github.com/e2b-dev/e2b-cookbook.git
    cd e2b-cookbook/examples/openenv-terminus-python
    uv sync --frozen
    cp .env.example .env
  2. 2. Set E2B_API_KEY in .env and start the server

    uv run --frozen uvicorn server:app --host 127.0.0.1 --port 8010
  3. 3. Run the repair demo

    uv run --frozen main.py
  4. 4. Drive an episode from Python

    import shlex
    
    from dotenv import load_dotenv
    from episode import BUGGY, PROGRAM, ReportEpisode
    
    load_dotenv()
    episode = ReportEpisode()
    try:
        print(episode.reset())
        print(episode.terminal(f"cat {PROGRAM}; python3 -B {PROGRAM}"))
        fixed = BUGGY.replace(
            '= int(row["amount"])',
            '= totals.get(row["region"], 0) + int(row["amount"])',
        )
        episode.terminal(f"printf %s {shlex.quote(fixed)} > {PROGRAM}")
        print(episode.submit())
        print(episode.get_reward())
    finally:
        episode._close()

Security

What runs in the sandbox

Episode code runs in E2B, away from your trainer. The OpenEnv server, inference and training stay on your own compute.

  • CodeTerminal commands from the policy run in an E2B episode sandbox, through OpenEnv's native reset and step calls.
  • StateFiles persist across steps within an episode. Each command gets a fresh shell, and reset replaces the whole sandbox.
  • GradingSubmitted code runs in a fresh verifier sandbox with outbound access off. Expected answers stay on the host.
  • SecretsYour E2B key stays on the host, and the local server binds to loopback.

3B+ sandboxes started

Give every agent a machine