# openai/universe architecture

> Architecture diagram of the GitHub repository openai/universe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openai/universe
- Repository: https://github.com/openai/universe

## Overview

Universe exposes interactive applications as Gym environments: an agent steps through a client environment, which sends keyboard and mouse actions to a containerized remote and returns screen observations, rewards, and episode status. Environment registration and wrappers configure the agent-facing interface; vectorization and diagnostics support scaled runs. VNC carries display and input traffic, while a WebSocket reward channel carries reward and control messages. The README and source index establish the major boundaries; several internal dispatch details are not shown in the excerpts, so links to those are omitted or marked unverified.

Main entry points: [`universe/envs/vnc_env.py`](https://github.com/openai/universe/blob/master/universe/envs/vnc_env.py) (VNC environment client), [`universe/wrappers`](https://github.com/openai/universe/tree/master/universe/wrappers) (Gym wrappers), [`universe/rewarder/rewarder_session.py`](https://github.com/openai/universe/blob/master/universe/rewarder/rewarder_session.py) (Reward session), [`universe/vncdriver/vnc_client.py`](https://github.com/openai/universe/blob/master/universe/vncdriver/vnc_client.py) (VNC protocol client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent_api["Agent interface"]
  node_registration["Environment registry<br/>[__init__.py]"]
  node_wrappers["Gym wrappers"]
  node_vector_core["Vector environments<br/>[core.py]"]
  node_vector_process["Multiprocess vectorizer"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
end

subgraph group_environment["Environment runtime"]
  node_vnc_env["VNC environment client<br/>[vnc_env.py]"]
  node_game_envs["Game and browser environments<br/>[vnc_core_env.py]"]
  node_twisty["Twisted event loop<br/>[twisty.py]"]
end

subgraph group_remote_runtime["Remote management"]
  node_runtime_registry["Runtime specifications<br/>[registration.py]"]
  node_allocator["Remote allocator"]
  node_docker_remote["Docker remote<br/>[docker_remote.py]"]
  node_remote_base["Remote interface<br/>[remote.py]"]
  node_container["Environment container<br/>[container.py]"]
end

subgraph group_vnc_transport["VNC transport"]
  node_spaces["VNC action and event spaces<br/>[vnc_event.py]"]
  node_vnc_session["VNC session<br/>[libvnc_session.py]"]
  node_vnc_client["VNC protocol client<br/>[vnc_client.py]"]
  node_server_messages["VNC server messages<br/>[server_messages.py]"]
end

subgraph group_reward_channel["Reward channel"]
  node_reward_session["Reward session"]
  node_reward_client["Reward WebSocket client<br/>[rewarder_client.py]"]
  node_env_status["Episode status<br/>[env_status.py]"]
  node_reward_buffer["Reward buffer<br/>[reward_buffer.py]"]
  node_reward_merge["Reward aggregation<br/>[merge.py]"]
end

node_agent(("Training agent"))
node_docker["Docker service"]
node_application["Hosted application"]
node_reward_service["Reward service"]

node_agent -->|"selects environment"| node_registration
node_registration -->|"registers entry points"| node_wrappers
node_agent -->|"steps environment"| node_wrappers
node_wrappers -->|"delegates to"| node_vnc_env
node_wrappers -->|"translates actions"| node_game_envs
node_vector_core -->|"wraps environments"| node_wrappers
node_vector_process -->|"uses vector core"| node_vector_core
node_diagnostics -.->|"supports inspection"| node_vnc_env
node_vnc_env -->|"uses action spaces"| node_spaces
node_vnc_env -->|"builds remotes"| node_allocator
node_vnc_env -->|"sends VNC actions"| node_vnc_session
node_vnc_env -->|"queues rewards"| node_reward_session
node_runtime_registry -->|"configures runtime"| node_docker_remote
node_allocator -->|"uses remote interface"| node_remote_base
node_docker_remote -->|"implements interface"| node_remote_base
node_docker_remote -->|"manages containers"| node_container
node_container -.->|"starts container"| node_docker
node_docker -->|"hosts application"| node_application
node_application -->|"serves display"| node_vnc_client
node_vnc_session -->|"uses protocol client"| node_vnc_client
node_vnc_client -->|"parses messages"| node_server_messages
node_vnc_client -.->|"sends input events"| node_spaces
node_reward_session -->|"connects clients"| node_reward_client
node_reward_client -->|"records rewards"| node_reward_buffer
node_reward_buffer -->|"tracks episode status"| node_env_status
node_reward_session -.->|"aggregates rewards"| node_reward_merge
node_reward_service -->|"sends reward messages"| node_reward_client
node_reward_session -->|"uses event loop"| node_twisty

click node_registration "https://github.com/openai/universe/blob/master/universe/__init__.py"
click node_wrappers "https://github.com/openai/universe/tree/master/universe/wrappers"
click node_vector_core "https://github.com/openai/universe/blob/master/universe/vectorized/core.py"
click node_vector_process "https://github.com/openai/universe/blob/master/universe/vectorized/multiprocessing_env.py"
click node_diagnostics "https://github.com/openai/universe/blob/master/universe/envs/diagnostics.py"
click node_vnc_env "https://github.com/openai/universe/blob/master/universe/envs/vnc_env.py"
click node_game_envs "https://github.com/openai/universe/blob/master/universe/envs/vnc_core_env/vnc_core_env.py"
click node_runtime_registry "https://github.com/openai/universe/blob/master/universe/runtimes/registration.py"
click node_allocator "https://github.com/openai/universe/blob/master/universe/remotes/allocator_remote.py"
click node_docker_remote "https://github.com/openai/universe/blob/master/universe/remotes/docker_remote.py"
click node_remote_base "https://github.com/openai/universe/blob/master/universe/remotes/remote.py"
click node_container "https://github.com/openai/universe/blob/master/universe/remotes/compose/container.py"
click node_spaces "https://github.com/openai/universe/blob/master/universe/spaces/vnc_event.py"
click node_vnc_session "https://github.com/openai/universe/blob/master/universe/vncdriver/libvnc_session.py"
click node_vnc_client "https://github.com/openai/universe/blob/master/universe/vncdriver/vnc_client.py"
click node_server_messages "https://github.com/openai/universe/blob/master/universe/vncdriver/server_messages.py"
click node_reward_session "https://github.com/openai/universe/blob/master/universe/rewarder/rewarder_session.py"
click node_reward_client "https://github.com/openai/universe/blob/master/universe/rewarder/rewarder_client.py"
click node_env_status "https://github.com/openai/universe/blob/master/universe/rewarder/env_status.py"
click node_reward_buffer "https://github.com/openai/universe/blob/master/universe/rewarder/reward_buffer.py"
click node_reward_merge "https://github.com/openai/universe/blob/master/universe/rewarder/merge.py"
click node_twisty "https://github.com/openai/universe/blob/master/universe/twisty.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_registration,node_wrappers,node_vector_core,node_vector_process,node_diagnostics toneBlue
class node_vnc_env,node_game_envs,node_twisty toneAmber
class node_runtime_registry,node_allocator,node_docker_remote,node_remote_base,node_container toneMint
class node_spaces,node_vnc_session,node_vnc_client,node_server_messages toneRose
class node_reward_session,node_reward_client,node_env_status,node_reward_buffer,node_reward_merge,node_agent,node_docker,node_application,node_reward_service toneIndigo
```

## Components

### Agent interface

- [Environment registry](https://github.com/openai/universe/blob/master/universe/__init__.py): `universe/__init__.py`
- [Gym wrappers](https://github.com/openai/universe/tree/master/universe/wrappers): `universe/wrappers`
- [Vector environments](https://github.com/openai/universe/blob/master/universe/vectorized/core.py): `universe/vectorized/core.py`
- [Multiprocess vectorizer](https://github.com/openai/universe/blob/master/universe/vectorized/multiprocessing_env.py): `universe/vectorized/multiprocessing_env.py`
- [Diagnostics](https://github.com/openai/universe/blob/master/universe/envs/diagnostics.py): `universe/envs/diagnostics.py`

### Environment runtime

- [VNC environment client](https://github.com/openai/universe/blob/master/universe/envs/vnc_env.py): `universe/envs/vnc_env.py`
- [Game and browser environments](https://github.com/openai/universe/blob/master/universe/envs/vnc_core_env/vnc_core_env.py): `universe/envs/vnc_core_env/vnc_core_env.py`
- [Twisted event loop](https://github.com/openai/universe/blob/master/universe/twisty.py): `universe/twisty.py`

### Remote management

- [Runtime specifications](https://github.com/openai/universe/blob/master/universe/runtimes/registration.py): `universe/runtimes/registration.py`
- [Remote allocator](https://github.com/openai/universe/blob/master/universe/remotes/allocator_remote.py): `universe/remotes/allocator_remote.py`
- [Docker remote](https://github.com/openai/universe/blob/master/universe/remotes/docker_remote.py): `universe/remotes/docker_remote.py`
- [Remote interface](https://github.com/openai/universe/blob/master/universe/remotes/remote.py): `universe/remotes/remote.py`
- [Environment container](https://github.com/openai/universe/blob/master/universe/remotes/compose/container.py): `universe/remotes/compose/container.py`

### VNC transport

- [VNC action and event spaces](https://github.com/openai/universe/blob/master/universe/spaces/vnc_event.py): `universe/spaces/vnc_event.py`
- [VNC session](https://github.com/openai/universe/blob/master/universe/vncdriver/libvnc_session.py): `universe/vncdriver/libvnc_session.py`
- [VNC protocol client](https://github.com/openai/universe/blob/master/universe/vncdriver/vnc_client.py): `universe/vncdriver/vnc_client.py`
- [VNC server messages](https://github.com/openai/universe/blob/master/universe/vncdriver/server_messages.py): `universe/vncdriver/server_messages.py`

### Reward channel

- [Reward session](https://github.com/openai/universe/blob/master/universe/rewarder/rewarder_session.py): `universe/rewarder/rewarder_session.py`
- [Reward WebSocket client](https://github.com/openai/universe/blob/master/universe/rewarder/rewarder_client.py): `universe/rewarder/rewarder_client.py`
- [Episode status](https://github.com/openai/universe/blob/master/universe/rewarder/env_status.py): `universe/rewarder/env_status.py`
- [Reward buffer](https://github.com/openai/universe/blob/master/universe/rewarder/reward_buffer.py): `universe/rewarder/reward_buffer.py`
- [Reward aggregation](https://github.com/openai/universe/blob/master/universe/rewarder/merge.py): `universe/rewarder/merge.py`

### Other components

- **Training agent**
- **Docker service**
- **Hosted application**
- **Reward service**

## Connections

- Training agent → Environment registry: selects environment
- Environment registry → Gym wrappers: registers entry points (evidence: `universe/__init__.py`)
- Training agent → Gym wrappers: steps environment
- Gym wrappers → VNC environment client: delegates to (evidence: `universe/wrappers/gym_core.py`)
- Gym wrappers → Game and browser environments: translates actions (evidence: `universe/wrappers/gym_core.py`)
- Vector environments → Gym wrappers: wraps environments (evidence: `universe/vectorized/core.py`)
- Multiprocess vectorizer → Vector environments: uses vector core (evidence: `universe/vectorized/multiprocessing_env.py`)
- Diagnostics → VNC environment client: supports inspection (evidence: `universe/envs/vnc_env.py`)
- VNC environment client → VNC action and event spaces: uses action spaces
- VNC environment client → Remote allocator: builds remotes (evidence: `universe/envs/vnc_env.py`)
- VNC environment client → VNC session: sends VNC actions (evidence: `universe/envs/vnc_env.py`)
- VNC environment client → Reward session: queues rewards
- Runtime specifications → Docker remote: configures runtime (evidence: `universe/remotes/docker_remote.py`)
- Remote allocator → Remote interface: uses remote interface (evidence: `universe/remotes/allocator_remote.py`)
- Docker remote → Remote interface: implements interface (evidence: `universe/remotes/docker_remote.py`)
- Docker remote → Environment container: manages containers (evidence: `universe/remotes/docker_remote.py`)
- Environment container → Docker service: starts container
- Docker service → Hosted application: hosts application
- Hosted application → VNC protocol client: serves display
- VNC session → VNC protocol client: uses protocol client (evidence: `universe/vncdriver/libvnc_session.py`)
- VNC protocol client → VNC server messages: parses messages (evidence: `universe/vncdriver/vnc_client.py`)
- VNC protocol client → VNC action and event spaces: sends input events
- Reward session → Reward WebSocket client: connects clients (evidence: `universe/rewarder/rewarder_session.py`)
- Reward WebSocket client → Reward buffer: records rewards (evidence: `universe/rewarder/rewarder_client.py`)
- Reward buffer → Episode status: tracks episode status (evidence: `universe/rewarder/reward_buffer.py`)
- Reward session → Reward aggregation: aggregates rewards
- Reward service → Reward WebSocket client: sends reward messages
- Reward session → Twisted event loop: uses event loop (evidence: `universe/rewarder/rewarder_session.py`)
