---
title: 'OSGym: Scalable OS Agents and O-RAN AI'
url: https://www.emergentmind.com/topics/osgym
type: topic
---

# OSGym: Scalable OS Agents and O-RAN AI

OSGym refers to two independent, open-source platforms, each addressing distinct research domains. In current literature, OSGym designates either a super-scalable distributed data engine for training generalizable computer-use agents [2511.11672] or, as a synonym for OpenRAN Gym, a unified platform for AI/ML development and testing in Open Radio Access Networks (O-RAN) [2207.12362]. Below, both systems are rigorously described in accordance with their scholarly sources.

## 1. OSGym for Computer Agents: Distributed OS-based Training Engine

OSGym [2511.11672] is a super-scalable distributed data engine designed for agent training across diverse computer-related OS tasks. The system is built to run and orchestrate thousands of full-featured Linux environment replicas via Docker containers, offering a Gym-style interface for training loops, scalable trajectory generation, and seamless integration with supervised and reinforcement learning workflows.

### Key Architectural Components

- **OS Replicas**: Each replica runs a full Linux environment inside a Docker container and supports arbitrary desktop applications (office suites, browsers, development tools, etc.).
- **State Managers**: One per replica, exposing a Gym-style API (`configure`, `reset`, `step`, `evaluate`), providing low-level OS control (start, reset, health check, recovery) and operating independently to enhance failure isolation.
- **Centralized Data Server**: A Python-based multiplexing server that manages batched asynchronous reset and step calls, balances load, and obfuscates underlying replica details to the user script (training loop).
- **Orchestrator/Scheduler**: Optimizes physical or cloud resource placement, balancing the number of replicas per host to minimize CPU costs by leveraging large-RAM hosts.

The decentralized state manager architecture eliminates single-point bottlenecks; faults are confined to individual replicas and rapidly recovered, enabling near-linear scalability in throughput and robust distributed operation.

## 2. Scalability, Performance, and Cost Analysis

OSGym achieves nearly linear throughput scaling, with empirical results demonstrating up to 1024 replicas managed simultaneously at an incremental cost of 0.2–0.3 USD/day per replica. Throughput is modeled as:
$$
T(N,R) \approx \eta(R) \cdot N
$$
where $T(N,R)$ is trajectories/minute, $N$ the replica count, and $\eta(R)$ the per-replica rate depending on resource allocation $R$. Using large-RAM hosts, a typical empirical value is $\eta \approx 1.39$ trajectories/minute/replica. At maximum evaluated scale ($N=1024$), the system generates 1420 multi-turn trajectories per minute, with average step latency increasing less than 5% across the full scale. Full cluster recovery after total crash completes within $O(60\,s)$.

The cost model is:
$$
C = c_{\text{replica}} \times N \times t
$$
where $C$ is total cost, $c_{\text{replica}}$ the daily per-replica cost, $N$ the number of replicas, $t$ the duration in days. Empirically, $c_{\text{replica}}$ remains within $[0.2, 0.3]$ USD/day, making large-scale training feasible for academic researchers.

## 3. Task and API Generality, Customizability

OSGym supports a unified four-stage API:

1. `configure(task_spec)`: Install and configure requisite software/data for the task.
2. `reset()`: Restore a pristine snapshot state.
3. `step(action)`: Execute low-level interactions (keystrokes, mouse, APIs), return screenshot, metadata, and reward.
4. `evaluate()`: Programmatic evaluation supporting arbitrary scalar metrics and custom success/failure definitions.

Application domains include office productivity (LibreOffice), browsers (Chrome), IDEs (VS Code), multimedia (GIMP, VLC), email (Thunderbird), file management, and complex multi-app workflows. Users may extend StateManager subclasses for additional OS APIs, wrap the DataServer for curriculum or prioritized sampling, and implement programmatic or human-in-the-loop evaluation.

## 4. Data Pipeline and Training Integration

The DataServer exposes a batched `.reset()`/`.step()` interface, streaming tuples of (state, action, thought, reward) into memory or disk storage. Each StateManager logs all relevant session data (screenshots, actions, timestamps).

- **Supervised Fine-Tuning**: Data is formatted as interleaved sequences (instruction $\to$ screenshot $\to$ thought $\to$ action), optimized under cross-entropy loss using Adam (learning rate $1e$–5, batch size 64).
- **Reinforcement Learning**: A semi-online asynchronous loop (rollouts and model update) realizes PPO (Proximal Policy Optimization) with learning rate $1e$–6, batch size 64, and 5000 update steps.

## 5. Experimental Benchmarks and Applications

The system was evaluated on 89 OSWorld tasks, compared against GPT-4o, Agent-S2, CogAgent, UI-TARS-1.5, Claude Computer-Use, and Aguvis-72B. OSGym-trained models achieved Pass@1 = 34.54% (vs prior best 33.93%) and Pass@5 = 47.34% (vs prior best 38.02%) on task completion within 25 steps.

Case studies include:

- **Large-Scale Data Generation**: 1024 replicas generated 244 novel task prompts (various applications) in 121 seconds (vs 115,654 seconds single-threaded) at a total cloud cost of 43 USD.
- **Finetuning**: Qwen-2.5-VL 7B model finetuned in ≈12 hours (8×H100 GPUs), outperforming baselines prior to RL.
- **Semi-Online PPO RL**: >20 steps/sec continuous rollouts across 1024 replicas, yielding +3–5% Pass@1 improvement over supervised baseline.

OSGym is fully open-source (MIT licensed).

## 6. OpenRAN Gym / OSGym for O-RAN AI/ML Research

OpenRAN Gym (occasionally “OSGym” in the literature) [2207.12362] is an open, O-RAN-compliant platform for developing, prototyping, and evaluating AI/ML xApps in experimental wireless environments.

### Main System Blocks

- **Experimental Platforms**: Colosseum, Arena, POWDER, COSMOS testbeds.
- **Softwarized RAN and Data Collection**: srsRAN (3GPP LTE/NR stack), SCOPE (network slicing, scheduler APIs, run-time control, detailed logs via Python/REST APIs).
- **Near-RT RIC (ColO-RAN)**: E2 Termination, E2 Manager, RMR Router (handles E2 messaging), Redis database, xApp SDK.
- **Virtualization**: LXC containers for SCOPE/ColO-RAN, Docker containers for services and xApps.

O-RAN interface compliance is maintained via E2 (near-RT control/data), internal RMR, and partial/optional A1 and O1 support for non-RT and management tasks.

## 7. Data Collection, xApp Workflows, and Experimental Evaluation

Data collection uses automated scenarios (e.g., Colosseum: 7 gNodeBs, 42 UEs) with configuration through JSON files and launch scripts. Detailed per-TTI/per-UE measurements—transport blocks, PRB utilization, buffer occupancy, CQI, throughput, and PHY layer latency—are logged to CSV for downstream modeling and analysis.

Key metrics include aggregate throughput ($T = \sum_{u=1}^U R_u$), PRB efficiency, buffer occupancy as latency proxy, Jain’s fairness index, and packet success ratio.

The xApp development workflow supports:

- Raw data collection and trace parsing.
- Feature extraction; training and validation with PPO-based actor-critic (cf. $L^{\mathrm{PPO}}(\theta)$).
- Reward functions combining broadband transport block maximization and time-sensitive buffer minimization.
- Packaging and deployment of xApps as Docker images; online inference and fine-tuning via E2 subscription/control.
- Result transfer across testbeds using LXC image export/import and launch scripts.

Evaluation on Colosseum (static urban scenario, 10 MHz downlink, no UE mobility) showed “sched-slicing” xApp raised median broadband TBs (+40%) and reduced time-sensitive buffer occupancy (–40%) compared to baselines. Experimentation is portable across Arena, POWDER, and COSMOS via containerization and scripting.

OpenRAN Gym/OSGym and associated code are public at https://openrangym.com.

## Comparative Table

| OSGym for Agents [2511.11672] | OpenRAN Gym / OSGym [2207.12362] |
|-------------------------------|-----------------------------------|
| Distributed OS simulation, agent training | O-RAN AI/ML xApp prototyping |
| Gym-style API (configure/reset/step/evaluate) | SCOPE + srsRAN, E2/RMR APIs |
| Scales to >1000 OS replicas | Emulates multi-gNB/UE RAN setups |
| 0.2–0.3 USD/replica/day | Portable to multiple testbeds |
| RL, supervised training | RL-based xApps, online fine-tuning |

Both platforms exemplify scalable, open-source infrastructure for academic and commercial AI/ML research, but target distinct technical domains: computer-use agent training (OS-level interactions) vs. O-RAN network control (wireless infrastructure).

Source: https://www.emergentmind.com/topics/osgym