Skip to main content

Overview

OpenEnv is an open-source framework from Meta’s PyTorch team for defining, deploying, and interacting with environments in RL and agentic workflows. It gives you Gym-style APIs (reset(), step(), state()) wrapped in HTTP clients (for example BrowserGymEnv, EchoEnv, TextArenaEnv), and lets you run those environments:
  • As local Python processes.
  • Inside Docker containers.
  • As hosted Hugging Face Spaces.
Eval Protocol integrates with OpenEnv by talking only to the environment client. Once an environment is exposed as an OpenEnv client, Eval Protocol can drive episodes without any environment-specific code in your tests. OpenEnvRolloutProcessor is the component that runs the OpenEnv loop for you:
  • It calls env.reset() to start an episode for each EvaluationRow.
  • For each step, it builds a user message from the observation, calls your model, parses the model’s response into an action, and calls env.step(action).
  • It appends a sentinel system message with per-step rewards so your @evaluation_test can compute a final score in a single place.
You can use the same pattern to write evals for any OpenEnv environment (BrowserGym, Echo, TextArena, Atari-style games, etc.) by changing only:
  • Which OpenEnv client you pass (BrowserGymEnv, EchoEnv, TextArenaEnv, …).
  • How you build prompts (prompt_builder).
  • How you parse actions (action_parser).

How to use OpenEnvRolloutProcessor

At a high level:
  1. Pick an OpenEnv client for your environment (see the OpenEnv environments for a full list):
    • BrowserGym: from envs.browsergym_env import BrowserGymEnv, BrowserGymAction
    • Echo: from envs.echo_env import EchoEnv, EchoAction
    • TextArena: from envs.textarena_env import TextArenaEnv, TextArenaAction
  2. Write a prompt_builder(observation, step, history) that turns the current observation into a user-facing prompt string (or chat messages).
  3. Write an action_parser(response_text) that converts model output into the environment’s Action type.
  4. Instantiate OpenEnvRolloutProcessor with the right constructor kwargs:
    • env_client_cls or env_factory (how to construct the client).
    • prompt_builder and action_parser.
    • Environment wiring:
      • docker_image and env_vars for Docker-based envs (BrowserGym, TextArena).
      • hub_repo_id to launch from Hugging Face Hub (for example "openenv/echo-env").
      • env_base_url when connecting to an already running server or remote Space.
    • Optional task routing:
      • tasks and task_var if you want to rotate across multiple tasks (for example multiple MiniWoB levels).
  5. Use it in an @evaluation_test:
    • Set rollout_processor=OpenEnvRolloutProcessor(...).
    • In the test body, read the step rewards sentinel from row.messages and set row.evaluation_result based on whatever scoring you want.
Concrete examples of prompt_builder and action_parser can be found in the Eval Protocol Python SDK:

BrowserGym example (MiniWoB via Docker)

openenv_browsergym_eval.py
This pattern generalizes to any OpenEnv client:
  • Swap BrowserGymEnv / BrowserGymAction for EchoEnv / EchoAction, TextArenaEnv / TextArenaAction, or your own environment class.
  • Keep prompt_builder and action_parser aligned with the environment’s observation and action types.
  • Reuse the same @evaluation_test file across offline evals, dashboards, and RL integrations that call Eval Protocol.

Echo / TextArena and connection modes

OpenEnvRolloutProcessor can construct environments in three main ways, all driven by env_client_cls:
  • From Hugging Face Hub (recommended)from_hub:
    When you use EchoEnv.from_hub("openenv/echo-env"), OpenEnv will pull and start the container for you locally. Internally it runs a command similar to:
    You typically do not need to run this yourself; it is shown here so you know what OpenEnv is doing under the hood and can debug or run it manually if needed.
  • Local / Docker image (TextArena, BrowserGym, custom)from_docker_image:
  • Existing HTTP server / remote Spacebase_url:
    With OpenEnvRolloutProcessor, you can pass a factory instead of env_client_cls:
Once your OpenEnv client is wired into OpenEnvRolloutProcessor, all Eval Protocol tooling (evaluation tests, logs UI, and integrations like TRL/rLLM) can reuse the same environment + reward logic by simply pointing at your @evaluation_test function via its module path.