All posts
Reinforcement Learning
Modal Team
15 min read

Best Sandboxes for Self-Play RL Environments in 2026

Modal Sandboxes in production

Self-play reinforcement learning has powered some of the most significant AI breakthroughs of the past decade, from mastering Go to training large language models that reason through complex problems. But the effectiveness of self-play hinges on one critical factor: the environment where agents compete, collaborate, and learn. Large-scale self-play deployments, and especially workloads that execute untrusted or agent-generated code, may require secure sandboxes that can scale to thousands of concurrent agents while maintaining isolation, consistent startup, and efficient use of CPU and memory. Smaller or classical self-play experiments do not inherently need that level of isolation or concurrency.

This guide examines seven platforms for self-play RL in 2026, spanning production-ready cloud sandbox infrastructure to specialized self-play RL environment, simulation, and API frameworks that can be run on or alongside sandbox infrastructure. Whether you're training game-playing agents, developing multi-agent social intelligence, or using self-play to improve LLM reasoning, these platforms offer distinct approaches to the challenge. The list starts with Modal, a scalable, high-performance sandbox platform for executing AI-generated code at production scale.

Key Takeaways

  • Environment concurrency sets the size of a self-play run: Self-play gets its training signal from many matches running at once. Modal has demonstrated creating 1M+ sandboxes in under a minute, at more than 10,000 sandbox creations per second. It supports up to 1M concurrent Sandboxes and reports running 3 billion sandboxes as of October 2026.
  • CPU and memory bursting reduces cost and overprovisioning for self-play: Self-play episodes are uneven, with environments idling while the policy model chooses its next move and then spiking when the game engine simulates a turn or agent-written code runs. Fixed-reservation pricing makes teams size every environment for the heaviest match, which keeps utilization low and costs high relative to the work done. Modal Sandboxes automatically burst above their requested CPU and memory, so teams can provision for typical usage rather than peak usage, with a lower risk of out-of-memory failures. Each Sandbox is billed per second on the greater of its requested and actual resources.
  • Consistent startup under load keeps episodes moving: Episodic training resets environments constantly. Modal keeps sandbox starts sub-second and consistent at high concurrency, including with large custom images that bundle game engines, simulators, and dependencies.
  • Isolation matters when agents generate code: Modal offers VM sandboxes and gVisor sandboxes, so self-play agents that write or execute code stay contained.
  • GPU requirements are workload-dependent: Large neural-policy and LLM self-play workloads commonly benefit from GPU acceleration, whereas classical or lightweight self-play environments can run on CPUs. Modal offers GPU-enabled Sandboxes alongside CPU Sandboxes, so teams can match compute resources across CPUs and GPUs to the workload.
  • Game-theoretic frameworks cover classical RL research: OpenSpiel provides well over 50 game environments covering perfect and imperfect information games, and researchers use it to study Nash equilibria and multi-agent strategy.
  • 3D environments support physics-based behavioral training: Unity ML-Agents enables self-play in physics-based simulations, supporting 2D, 3D, VR, and AR environments with competitive examples such as Tennis and Soccer.
  • Text-based games are emerging as LLM training tools: SPIRAL, using text-game environments drawn from TextArena, demonstrates that self-play can transfer to broader reasoning benchmarks. Its authors report gains of up to 10% across a suite of eight reasoning benchmarks on four models, with multi-game training on TicTacToe, Kuhn Poker, and Simple Negotiation giving the strongest results.
  • Standardized APIs support research reproducibility: PettingZoo provides an API standard for multi-agent RL that interoperates with several major libraries, giving teams one interface for comparing algorithms across environments.

1. Modal

Modal is a scalable, high-performance sandbox platform for executing AI-generated code at production scale, and it supplies the infrastructure layer that self-play RL systems need to grow. While research frameworks provide environments and algorithms, Modal provides the compute fabric: high-concurrency Sandboxes with automatic CPU and memory bursting and consistent fast starts under load, plus GPU-enabled Sandboxes alongside CPU Sandboxes when environments need acceleration.

What Makes Modal Different for RL?

Self-play depends on running many environments in parallel, and Modal is built for that scale: it supports up to 1M concurrent Sandboxes, and each Sandbox can burst above its requested CPU and memory when an episode needs more. When agents need acceleration, Modal also offers GPU access inside isolated Sandboxes with full sandbox functionality. That capability matters for on-policy RL when environment instances need to run model inference alongside training. The platform supports GPUs ranging from T4 to B300, giving teams flexibility to match hardware to workload requirements, and the same Sandbox interface runs CPU-only environments for lighter self-play workloads.

Core capabilities for self-play RL:

  • Massive concurrency: Modal has demonstrated creating 1M+ sandboxes in under a minute, exceeding 10,000 creations per second, and its Sandboxes product page lists support for up to 1M concurrent Sandboxes. Modal regularly runs tens of thousands of concurrent customer sandboxes, and its custom-built scheduler keeps execution reliable as environment counts grow
  • Automatic CPU and memory bursting: Teams set a baseline of CPU and memory for each environment, and Sandboxes burst above that baseline when a match needs more. Billing is per second on the greater of requested and actual resources, so self-play environments can be provisioned for typical usage instead of peak usage. This active-resourcing model is a departure from the fixed-reservation billing that most Sandbox providers use
  • Consistent fast starts under load: Sandbox starts stay sub-second and consistent at high concurrency, with an optimized filesystem that helps containers come online quickly without letting large images slow startup down, which supports rapid environment instantiation
  • VM and gVisor isolation: Modal offers VM Sandboxes that run on full virtual machines and support full Docker functionality, as well as gVisor sandboxes that intercept syscalls at a kernel-level boundary to keep untrusted agent code contained
  • Code-first infrastructure: Sandboxes are defined and controlled in code, and Modal provides code-first SDKs in Python, TypeScript, and Go. The code running inside a Sandbox is not limited to a single language, so a Sandbox can run whatever runtime the workload requires
  • Snapshot support: Filesystem and directory snapshots let Sandbox state be restored quickly instead of rebuilt from scratch, with directory snapshots letting teams separate project state from platform-owned dependencies
  • SWE-bench evaluation support: In its January 2025 Sandbox GA announcement, Modal reported upstreaming an execution option for Modal into SWE-bench
  • Multi-cloud capacity: Multi-cloud capacity pooling provides reliable CPU and GPU availability
  • GPU sandboxes when environments need them: Modal offers feature-complete GPU Sandboxes on 10+ GPU types, including B300, B200, H200, and H100, without reservations. GPU Sandboxes run on the gVisor runtime

Why Modal for Self-Play Architecture?

Self-play training involves running many copies of an environment simultaneously, each hosting agents that learn by competing against themselves or previous versions. This requires infrastructure that can:

  1. Launch thousands of isolated environments quickly
  2. Match capacity to training needs
  3. Maintain security when running agent-generated code
  4. Provide GPU access for neural network inference within each environment when the policy requires it

Modal's combination of high-concurrency Sandbox creation, automatic CPU and memory bursting, consistent starts under load, and GPU Sandboxes for accelerated environments addresses these requirements directly. Modal automatically handles the underlying scheduling and infrastructure, and Modal Functions autoscale their container pools up and down, including to zero. Sandboxes use a different abstraction: the application creates and manages Sandbox instances explicitly through the Sandbox API, which can be orchestrated at very high concurrency, including from Functions. In its January 2025 Sandbox GA announcement, Modal reported running SWE-bench Verified's 500 tasks in 7 minutes on its infrastructure.

Security and Compliance

Modal has completed a SOC 2 Type 2 audit and supports HIPAA-compliant workloads on Enterprise plans via a BAA. Self-play environments are isolated in VM or gVisor sandboxes, public APIs use TLS 1.3, and data is encrypted in transit and at rest. Modal supports region-pinning.

Why Teams Choose Modal for Self-Play RL

  • League-scale match throughput: Modal has demonstrated creating 1M+ sandboxes in under a minute and running over a million concurrent sandboxes, so a population of agents can play thousands of simultaneous matches without the environment layer holding back training
  • Active-resource billing for uneven episodes: A self-play environment waits while the policy picks its next move and then spikes when the simulator advances or agent-written code executes, so teams can request small Sandboxes sized for the typical match and let them burst instead of reserving capacity for the heaviest one
  • Fast, predictable resets: Episode resets rely on sandbox starts that stay sub-second as concurrency climbs, even with large custom images that package game engines and simulators
  • RL workloads in production: Cognition states that Modal powers both its RL infrastructure and its production inference, and Imbue orchestrates hundreds of isolated coding agents on Modal
  • The whole self-play loop on one platform: Environments run in Sandboxes, policy updates run on Modal's training product, and opponents can be served through its inference product, with GPU Sandboxes available when environment-side models need acceleration

2. OpenSpiel

OpenSpiel, developed by Google DeepMind, provides a toolkit for game-theoretic RL research, used by researchers studying strategic decision-making in multi-agent settings.

Capabilities

  • Game library: OpenSpiel offers well over 50 game environments spanning board games (chess, Go), card games (poker variants), and abstract strategic scenarios.
  • Game types: The framework supports n-player zero-sum, cooperative, and general-sum games.
  • Information structures: It covers both perfect information (chess) and imperfect information (poker) games, with sequential and simultaneous action.
  • Architecture: OpenSpiel has a C++ core with Python bindings and can be used as a C++ library as well as from Python.
  • Algorithm library: It includes implementations of CFR-family methods, MCTS, policy gradient methods, and more, so researchers can study Nash equilibrium computation, exploitation strategies, and regret minimization across a diverse set of well-defined games.
  • OpenSpiel 2.0: OpenSpiel 2.0 was announced on July 14, 2026, followed by 2.0.1 on July 17, adding structured state, action, and observation types, standardized trajectories, additional games, a JAX AlphaZero implementation, language-model-oriented examples, and MCP integration.

Considerations

  • Research toolkit scope: OpenSpiel provides game logic and algorithms, while compute provisioning, isolation, and scaling are handled by separate infrastructure.
  • Background knowledge: Practical use of either the C++ or Python interface generally benefits from familiarity with RL and game-theoretic concepts.

Why Teams Choose OpenSpiel

OpenSpiel is a game-theory research library rather than an execution platform. Teams choose OpenSpiel when their self-play research centers on equilibrium computation and strategy across well-defined games, and they plan to run it on separate compute.

3. Unity ML-Agents

Unity ML-Agents brings RL into three-dimensional, physics-based environments. The project remains actively maintained: Release 23 / 4.0.0 was published on August 28, 2025, and the current development documentation remains active.

Capabilities

  • Self-play implementation: Unity ML-Agents includes self-play support with team IDs, opponent snapshots, and configurable training parameters.
  • Multi-agent scenarios: The framework includes Soccer, Tennis, and custom competitive games, and it supports both competitive and cooperative multi-agent training.
  • Algorithm support: It supports PPO, SAC, and MA-POCA, and MA-POCA can be combined with self-play.
  • Curriculum learning: Curriculum learning is a distinct mechanism that progressively adjusts environment parameters and lessons, while self-play separately trains against current and historical opponent policies.
  • Simulation range: Self-play runs in 2D, 3D, VR, and AR simulations, and the platform's 17+ example environments provide starting points for custom scenarios, including concurrent environment instances.
  • Standard API compatibility: Gym and PettingZoo wrappers are available.

Considerations

  • Unity engine dependency: Unity ML-Agents requires familiarity with the Unity game engine plus Python for training scripts.
  • Game-development orientation: Unity also targets game-development workflows alongside research use.

Why Teams Choose Unity ML-Agents

Unity ML-Agents is a simulation toolkit built on a game engine. Teams choose it when their self-play agents need physics-based 3D, VR, or AR environments authored in Unity.

4. SPIRAL

SPIRAL is a research framework that uses self-play to improve language model capabilities. Released in June 2025, it demonstrates that playing text-based games against itself can enhance an LLM's general reasoning abilities.

Capabilities

  • Self-generated curriculum: SPIRAL uses zero-sum multi-turn text games to create an automatically evolving curriculum of progressively challenging problems, and as the model improves, its opponent (a copy of itself) also improves, which can maintain training pressure.
  • Role-conditioned Advantage Estimation (RAE): RAE is a technique for credit assignment in self-play.
  • TextArena integration: SPIRAL uses text games from TextArena as training environments.
  • Transferable improvements: In the current version of the paper, the authors report gains of up to 10% across eight reasoning benchmarks on four Qwen and Llama models, and multi-game training yields the strongest results.
  • Reduced reliance on curated data: Instead of depending on expert-curated problem-answer pairs, models generate their own curriculum through adversarial play, although training still takes place inside human-designed game environments and rules.
  • Distributed training: SPIRAL integrates with Tinker for multi-node training.

Considerations

  • Learning saturation: The authors note that fixed game environments can eventually saturate learning.
  • Training at scale: Running SPIRAL training at scale can require LLM-training and distributed-systems expertise. For teams looking to run SPIRAL at scale, Modal's training infrastructure provides multi-node GPU clusters for distributed self-play training.

Why Teams Choose SPIRAL

SPIRAL is a research method and codebase for LLM self-play rather than an environment host. Teams choose SPIRAL when they want to test text-game self-play as an alternative to supervised fine-tuning or RLHF for improving model reasoning.

5. MeltingPot

Melting Pot, another DeepMind project, focuses specifically on multi-agent social scenarios. A 2025 analysis of the Melting Pot contest describes over 50 substrates and more than 250 distinct test scenarios for evaluating social interaction and generalization in multi-agent systems.

Capabilities

  • Social generalization testing: Melting Pot tests whether agents can cooperate, compete, and coordinate with unfamiliar partners, not just the agents they trained with.
  • Cooperation scenarios: The suite includes commons dilemmas and public goods games.
  • Competition scenarios: Agents also contest resources and control territory against one another.
  • Mixed-motive and deception scenarios: Mixed-motive scenarios require both cooperation and competition, and deception scenarios cover trust games and signaling.
  • Held-out evaluation: The Melting Pot contest used held-out scenarios to evaluate cooperation and social generalization, and subsequent work continues to use Melting Pot as a social-generalization evaluation protocol.

Considerations

  • Benchmark scope: Melting Pot is an environment suite and evaluation protocol, so training compute and isolation come from separate infrastructure.
  • Research orientation: The project is aimed at multi-agent research rather than production deployment.

Why Teams Choose MeltingPot

Melting Pot is a multi-agent evaluation suite centered on social behavior. Teams choose it when they need to check whether self-play agents generalize to partners and situations they never saw in training.

6. TextArena

TextArena provides an open-source collection of text-based competitive games designed for LLM evaluation and training. The 2025 TextArena paper describes 57+ unique environments spanning single-agent, two-player, and multi-player settings, and TextArena maintains a current environment catalog in which some entries are marked as previews.

Capabilities

  • Gym-like interface: TextArena exposes a standard RL API for training integration.
  • Online play system: A TrueSkill™ leaderboard ranks models.
  • Model-to-model evaluation: Automated competitive evaluation feeds its leaderboards.
  • Human evaluation: TextArena supports human-vs-model comparisons.
  • Self-play game source: TextArena serves as the game source for SPIRAL and similar text-based self-play frameworks, and its standardized interface connects to LLM inference infrastructure.

Considerations

  • Training runs elsewhere: TextArena itself can be used for game interaction and evaluation without distributed training infrastructure, and large-scale training requires a separate stack.
  • Preview entries: Some environments in the current catalog are marked as previews.

Why Teams Choose TextArena

TextArena is a library of competitive text-game environments with evaluation tooling attached. Teams choose it when they need a varied pool of text games to drive LLM self-play training or model-versus-model evaluation.

7. PettingZoo

PettingZoo, maintained by the Farama Foundation (the organization behind Gymnasium), describes itself as an API standard for multi-agent reinforcement learning environments. Rather than offering a single type of environment, it provides a unified interface that works across many different multi-agent scenarios. It remains actively maintained, with release 1.27.0 published on August 13, 2026.

Capabilities

  • AEC (Agent Environment Cycle) API: The AEC pattern covers turn-based environments where agents act sequentially.
  • Parallel API: For simultaneous-action environments, the Parallel pattern lets all agents act at once.
  • Environment families: The library includes Atari (multi-player Atari games), Butterfly (cooperative scenarios), Classic (board games and card games), and SISL (Stanford Intelligent Systems Laboratory environments).
  • Library interoperability: PettingZoo interoperates with several RL libraries including RLlib, Tianshou, and AgileRL, and its documentation also covers Stable Baselines3, which PettingZoo's SB3 tutorials present as a parameter-sharing workflow adapted for multi-agent settings.
  • Self-play tutorial: The AgileRL tutorial specifically covers self-play and curriculum learning patterns.

Considerations

  • Interface layer: PettingZoo standardizes how environments are accessed, while compute, scaling, and isolation are handled outside the library.
  • Python library: PettingZoo is a Python library, so it requires Python proficiency.

Why Teams Choose PettingZoo

PettingZoo is an API standard and environment library for multi-agent RL. Teams choose PettingZoo when they want one interface across turn-based and simultaneous-action environments so self-play algorithms can be compared on equal terms.

Why Modal Stands Out for Self-Play RL Infrastructure

The Infrastructure Gap in RL

Many self-play frameworks focus primarily on environments, algorithms, and training abstractions rather than providing a complete managed compute layer, although some include distributed-training or concurrent-environment integrations: SPIRAL documents Tinker distributed-training support, and Unity supports concurrent environment instances. Even so, teams frequently must provision servers, manage GPU allocation, handle container orchestration, and ensure security before training a single agent.

Modal Closes This Gap

Modal provides the missing infrastructure layer with capabilities specifically suited to self-play workloads:

Massive Parallelism: Self-play training benefits from running many environment copies simultaneously. Modal has demonstrated creating 1M+ sandboxes in under a minute, exceeding 10,000 creations per second. Its Sandboxes support up to 1M concurrent instances, and Modal regularly runs tens of thousands of concurrent customer sandboxes.

CPU and Memory Bursting: Resource demand in self-play swings from match to match: a quick card game barely touches the CPU, while a physics-heavy episode or a turn that runs agent-written code can need several times more compute and memory. Fixed-reservation pricing pushes teams to size every environment for that worst case, so much of the reserved capacity goes unused. Each Modal Sandbox starts from the CPU and memory it requested and bursts above that level automatically when an episode calls for it, which lets teams provision for typical usage instead of peak usage. Billing is per second on the greater of requested and actual resources, and bursting also reduces the risk of out-of-memory failures that would cut an episode short.

Consistent Starts Under Load: Modal keeps sandbox starts sub-second and consistent as concurrency rises, with an optimized filesystem that helps containers come online quickly without letting large images slow startup down. That matters for episodic training where environments reset frequently, and it holds for large, custom images that package game engines, simulators, and their dependencies.

GPU-Enabled Sandboxes: When environments need acceleration, Modal supports GPU access inside isolated Sandboxes, with full sandbox functionality on GPU, alongside CPU Sandboxes for lighter environments. This matters for on-policy RL where each environment instance needs to run neural network inference.

Unified Platform: Beyond Sandboxes, Modal provides multi-node training spanning 1 to 64 GPUs with H100, H200, and B200 clusters on InfiniBand and private networking, inference endpoints for serving trained models, and batch processing for offline evaluation. Snorkel, for example, serves models on Modal and runs evals in Modal Sandboxes.

Security by Default: Running self-play means executing agent-generated actions, potentially including code. Modal offers gVisor sandboxes, which provide a kernel-level isolation boundary that intercepts syscalls and constrains the blast radius of malicious code, and VM Sandboxes that run on full virtual machines. Modal has completed a SOC 2 Type 2 audit, supports HIPAA-compliant workloads on Enterprise plans via a BAA, uses TLS 1.3 for public APIs, encrypts data in transit and at rest, and supports region-pinning.

Production-Ready from Day One

Modal's customers page lists production workloads including reinforcement learning, coding agents, sandboxed code execution, and real-time robot control, with Cognition stating that Modal powers both its RL infrastructure and its production inference, involving millions of sandboxes. Agent workloads are a proven pattern here as well: Ramp built a full-context background coding agent on Modal, generating code changes that are written back into commits and pull requests, and Imbue orchestrates hundreds of isolated coding agents on Modal. By Modal's count, its platform had run 3 billion sandboxes as of October 2026. For self-play RL, this means you're building on infrastructure that's already proven at scale.

Whether you're using OpenSpiel for research, Unity ML-Agents for 3D training, or SPIRAL for LLM improvement, Modal provides production infrastructure suited to running these kinds of systems reliably and at scale, with high concurrency, automatic CPU and memory bursting, and consistent starts under load. Explore Modal's sandbox documentation to get started.

Frequently Asked Questions

  • A sandbox environment provides an isolated, controlled space where RL agents can interact, compete, and learn without affecting external systems. For self-play specifically, sandboxes allow multiple copies of an agent to play against each other safely, generating training data from their interactions. Of the seven entries in this guide, only Modal is a secure execution sandbox in this infrastructure sense; the others are environment, simulation, toolkit, or API layers that can run inside such sandboxes.

  • Each platform approaches self-play differently. Modal provides infrastructure-level isolation through VM and gVisor sandboxes, where large numbers of sandboxed environments can run concurrently and burst above their requested CPU and memory, with GPU support available when needed. OpenSpiel and PettingZoo provide game logic and APIs for multi-agent interaction. Unity ML-Agents includes built-in self-play training modes with opponent snapshots. SPIRAL trains language models through self-play in text games drawn from TextArena, while TextArena supplies the environments and evaluation infrastructure.

  • Modal is best suited for resource-intensive simulations that need high parallelism, since it supports up to 1M concurrent Sandboxes and lets each one burst above its requested CPU and memory during heavy episodes. For neural network-based self-play, Modal's dedicated training and inference products handle policy updates and model serving, and GPU access inside isolated Sandboxes, with T4 through B300 support, covers environment-side models that need acceleration. For CPU-based game-theoretic research, OpenSpiel provides a C++ core as well as Python interfaces.

  • Modal is explicitly designed for production deployment. Modal has completed a SOC 2 Type 2 audit, supports HIPAA-compliant workloads on Enterprise plans via a BAA, and supports region-pinning. OpenSpiel, Unity ML-Agents, Melting Pot, TextArena, and PettingZoo are research-oriented environment, simulation, toolkit, or API layers, with Unity additionally targeting game-development workflows; you would typically train using these and then deploy trained models on production infrastructure like Modal.

  • PettingZoo is a Python library, so it requires Python proficiency. OpenSpiel supports both C++ and Python interfaces, and practical use of either generally benefits from familiarity with RL and game-theoretic concepts. Unity ML-Agents requires familiarity with the Unity game engine plus Python for training scripts. Running SPIRAL training at scale can require LLM-training and distributed-systems expertise, while TextArena itself can be used for game interaction and evaluation without distributed training. Modal defines and controls infrastructure in code, and it provides code-first SDKs in Python, TypeScript, and Go. The code running inside a Sandbox is not limited to a single language, so a Sandbox can run whatever runtime or language the workload requires, and the platform handles container orchestration, resource allocation, and scheduling.

  • SPIRAL demonstrates that competitive text games create an automatically evolving curriculum of progressively challenging problems. Unlike static datasets, self-play opponents improve alongside the model, helping maintain training pressure, though the authors note that fixed, human-designed game environments can still eventually saturate learning. The authors report gains of up to 10% across eight reasoning benchmarks on four models. Training on several games at once (TicTacToe, Kuhn Poker, and Simple Negotiation) gave the strongest results, suggesting that the competitive dynamics sharpen general reasoning capabilities beyond the specific game domains.

  • Modal bills on active resources. Each self-play environment requests a CPU and memory baseline, bursts above it automatically when a match turns compute-heavy, and is charged per second for whichever is greater, the requested or the actual resources. Teams can therefore size environments for an average match and still have headroom for long or complex ones, and automatic bursting lowers the chance that a game crashes with an out-of-memory error partway through. Most sandbox providers bill for a fixed reservation and cap usage at that size, so every environment has to be provisioned for the heaviest match, and teams pay for headroom that most episodes never touch.

View Sandboxes Docs

Run your first sandbox in minutes.

$30 in free compute to get started.