openenv 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. {openenv-0.2.0 → openenv-0.2.2}/PKG-INFO +150 -46
  2. openenv-0.2.0/src/openenv.egg-info/PKG-INFO → openenv-0.2.2/README.md +127 -83
  3. openenv-0.2.2/pyproject.toml +148 -0
  4. openenv-0.2.2/src/openenv/__init__.py +54 -0
  5. openenv-0.2.2/src/openenv/auto/__init__.py +39 -0
  6. openenv-0.2.2/src/openenv/auto/_discovery.py +584 -0
  7. openenv-0.2.2/src/openenv/auto/auto_action.py +276 -0
  8. openenv-0.2.2/src/openenv/auto/auto_env.py +897 -0
  9. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/__main__.py +10 -2
  10. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/_cli_utils.py +17 -14
  11. openenv-0.2.2/src/openenv/cli/_validation.py +594 -0
  12. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/commands/__init__.py +2 -2
  13. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/commands/build.py +12 -4
  14. openenv-0.2.2/src/openenv/cli/commands/fork.py +197 -0
  15. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/commands/init.py +0 -2
  16. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/commands/push.py +198 -21
  17. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/commands/serve.py +94 -94
  18. openenv-0.2.2/src/openenv/cli/commands/skills.py +200 -0
  19. openenv-0.2.2/src/openenv/cli/commands/validate.py +198 -0
  20. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/client.py +2 -2
  21. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/models.py +1 -2
  22. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/pyproject.toml +1 -1
  23. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/server/__ENV_NAME___environment.py +4 -1
  24. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/server/app.py +6 -3
  25. openenv-0.2.2/src/openenv/core/__init__.py +81 -0
  26. openenv-0.2.2/src/openenv/core/containers/runtime/daytona_provider.py +572 -0
  27. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/containers/runtime/providers.py +10 -2
  28. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/containers/test_local_docker_provider.py +0 -1
  29. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_client.py +169 -46
  30. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/__init__.py +74 -20
  31. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/exceptions.py +105 -105
  32. openenv-0.2.2/src/openenv/core/env_server/gradio_theme.py +128 -0
  33. openenv-0.2.2/src/openenv/core/env_server/gradio_ui.py +240 -0
  34. openenv-0.2.2/src/openenv/core/env_server/http_server.py +1646 -0
  35. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/interfaces.py +295 -194
  36. openenv-0.2.2/src/openenv/core/env_server/mcp_environment.py +672 -0
  37. openenv-0.2.2/src/openenv/core/env_server/mcp_types.py +321 -0
  38. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/route_config.py +57 -57
  39. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/serialization.py +171 -137
  40. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/types.py +52 -6
  41. openenv-0.2.2/src/openenv/core/env_server/web_interface.py +644 -0
  42. openenv-0.2.2/src/openenv/core/evals/__init__.py +18 -0
  43. openenv-0.2.2/src/openenv/core/evals/base.py +62 -0
  44. openenv-0.2.2/src/openenv/core/evals/inspect_harness.py +160 -0
  45. openenv-0.2.2/src/openenv/core/evals/types.py +40 -0
  46. openenv-0.2.2/src/openenv/core/generic_client.py +167 -0
  47. openenv-0.2.2/src/openenv/core/llm_client.py +506 -0
  48. openenv-0.2.2/src/openenv/core/mcp_client.py +484 -0
  49. openenv-0.2.2/src/openenv/core/rubrics/__init__.py +40 -0
  50. openenv-0.2.2/src/openenv/core/rubrics/base.py +195 -0
  51. openenv-0.2.2/src/openenv/core/rubrics/containers.py +574 -0
  52. openenv-0.2.2/src/openenv/core/rubrics/llm_judge.py +118 -0
  53. openenv-0.2.2/src/openenv/core/rubrics/trajectory.py +203 -0
  54. openenv-0.2.2/src/openenv/core/sync_client.py +263 -0
  55. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/tools/__init__.py +6 -1
  56. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/tools/local_python_executor.py +2 -4
  57. openenv-0.2.2/src/openenv/core/utils.py +59 -0
  58. openenv-0.2.0/README.md → openenv-0.2.2/src/openenv.egg-info/PKG-INFO +187 -45
  59. {openenv-0.2.0 → openenv-0.2.2}/src/openenv.egg-info/SOURCES.txt +26 -1
  60. {openenv-0.2.0 → openenv-0.2.2}/src/openenv.egg-info/requires.txt +25 -0
  61. {openenv-0.2.0 → openenv-0.2.2}/src/openenv_core/__init__.py +9 -1
  62. openenv-0.2.2/tests/test_line_endings.py +207 -0
  63. openenv-0.2.0/pyproject.toml +0 -80
  64. openenv-0.2.0/src/openenv/__init__.py +0 -12
  65. openenv-0.2.0/src/openenv/cli/_validation.py +0 -159
  66. openenv-0.2.0/src/openenv/cli/commands/validate.py +0 -108
  67. openenv-0.2.0/src/openenv/core/__init__.py +0 -16
  68. openenv-0.2.0/src/openenv/core/env_server/http_server.py +0 -935
  69. openenv-0.2.0/src/openenv/core/env_server/web_interface.py +0 -1621
  70. openenv-0.2.0/src/openenv/core/utils.py +0 -27
  71. {openenv-0.2.0 → openenv-0.2.2}/LICENSE +0 -0
  72. {openenv-0.2.0 → openenv-0.2.2}/setup.cfg +0 -0
  73. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/__init__.py +0 -0
  74. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/__init__.py +0 -0
  75. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/README.md +0 -0
  76. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/__init__.py +0 -0
  77. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/openenv.yaml +0 -0
  78. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/server/Dockerfile +0 -0
  79. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/server/__init__.py +0 -0
  80. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/cli/templates/openenv_env/server/requirements.txt +0 -0
  81. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/client_types.py +0 -0
  82. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/containers/__init__.py +0 -0
  83. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/containers/runtime/__init__.py +0 -0
  84. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/containers/runtime/uv_provider.py +0 -0
  85. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/env_server/base_transforms.py +0 -0
  86. {openenv-0.2.0 → openenv-0.2.2}/src/openenv/core/tools/git_server_client.py +0 -0
  87. {openenv-0.2.0 → openenv-0.2.2}/src/openenv.egg-info/dependency_links.txt +0 -0
  88. {openenv-0.2.0 → openenv-0.2.2}/src/openenv.egg-info/entry_points.txt +0 -0
  89. {openenv-0.2.0 → openenv-0.2.2}/src/openenv.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openenv
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A unified framework for reinforcement learning environments
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -17,6 +17,9 @@ Requires-Dist: openai>=2.7.2
17
17
  Requires-Dist: tomli>=2.3.0
18
18
  Requires-Dist: tomli-w>=1.2.0
19
19
  Requires-Dist: websockets>=15.0.1
20
+ Requires-Dist: fastmcp>=3.0.0
21
+ Requires-Dist: gradio>=4.0.0
22
+ Requires-Dist: httpx>=0.28.1
20
23
  Provides-Extra: core
21
24
  Requires-Dist: fastapi>=0.104.0; extra == "core"
22
25
  Requires-Dist: pydantic>=2.0.0; extra == "core"
@@ -31,9 +34,28 @@ Requires-Dist: huggingface_hub>=0.20.0; extra == "cli"
31
34
  Requires-Dist: openai>=2.7.2; extra == "cli"
32
35
  Requires-Dist: tomli>=2.3.0; extra == "cli"
33
36
  Requires-Dist: tomli-w>=1.2.0; extra == "cli"
37
+ Provides-Extra: docs
38
+ Requires-Dist: sphinx==7.2.6; extra == "docs"
39
+ Requires-Dist: pytorch-sphinx-theme2; extra == "docs"
40
+ Requires-Dist: sphinxcontrib.katex==0.9.10; extra == "docs"
41
+ Requires-Dist: docutils<0.21,>=0.18.1; extra == "docs"
42
+ Requires-Dist: sphinx-design==0.6.1; extra == "docs"
43
+ Requires-Dist: sphinxcontrib-mermaid==1.0.0; extra == "docs"
44
+ Requires-Dist: myst-parser; extra == "docs"
45
+ Requires-Dist: sphinxext-opengraph; extra == "docs"
46
+ Requires-Dist: sphinx-sitemap==2.7.1; extra == "docs"
47
+ Requires-Dist: sphinx-gallery>=0.14.0; extra == "docs"
48
+ Requires-Dist: matplotlib; extra == "docs"
49
+ Requires-Dist: nest-asyncio; extra == "docs"
50
+ Requires-Dist: smolagents; extra == "docs"
34
51
  Provides-Extra: all
35
52
  Requires-Dist: openenv[core]; extra == "all"
36
53
  Requires-Dist: openenv[cli]; extra == "all"
54
+ Provides-Extra: daytona
55
+ Requires-Dist: daytona>=0.136.0; extra == "daytona"
56
+ Requires-Dist: pyyaml>=6.0; extra == "daytona"
57
+ Provides-Extra: inspect
58
+ Requires-Dist: inspect-ai>=0.3.0; extra == "inspect"
37
59
  Dynamic: license-file
38
60
 
39
61
  # <img width="35" height="35" alt="image" src="https://github.com/user-attachments/assets/2700a971-e5d6-4036-b03f-2f89c9791609" /> OpenEnv: Agentic Execution Environments
@@ -49,10 +71,61 @@ An e2e framework for creating, deploying and using isolated execution environmen
49
71
 
50
72
  **🚀 Featured Example:** Train LLMs to play BlackJack using [torchforge](https://github.com/meta-pytorch/torchforge) (PyTorch's agentic RL framework): [`examples/grpo_blackjack/`](examples/grpo_blackjack/)
51
73
 
74
+ **🔥 Zero to Hero Tutorial:** End to end tutorial from our [GPU Mode](tutorial/README.md) lecture and other hackathons.
75
+
76
+ ## Quick Start
77
+
78
+ Install the OpenEnv core package:
79
+
80
+ ```bash
81
+ pip install openenv
82
+ ```
83
+
84
+ Install an environment client (e.g., Echo):
85
+
86
+ ```bash
87
+ pip install git+https://huggingface.co/spaces/openenv/echo_env
88
+ ```
89
+
90
+ Then use the environment:
91
+
92
+ ```python
93
+ import asyncio
94
+ from echo_env import EchoAction, EchoEnv
95
+
96
+ async def main():
97
+ # Connect to a running Space (async context manager)
98
+ async with EchoEnv(base_url="https://openenv-echo-env.hf.space") as client:
99
+ # Reset the environment
100
+ result = await client.reset()
101
+ print(result.observation.echoed_message) # "Echo environment ready!"
102
+
103
+ # Send messages
104
+ result = await client.step(EchoAction(message="Hello, World!"))
105
+ print(result.observation.echoed_message) # "Hello, World!"
106
+ print(result.reward) # 1.3 (based on message length)
107
+
108
+ asyncio.run(main())
109
+ ```
110
+
111
+ **Synchronous usage** is also supported via the `.sync()` wrapper:
112
+
113
+ ```python
114
+ from echo_env import EchoAction, EchoEnv
115
+
116
+ # Use .sync() for synchronous context manager
117
+ with EchoEnv(base_url="https://openenv-echo-env.hf.space").sync() as client:
118
+ result = client.reset()
119
+ result = client.step(EchoAction(message="Hello, World!"))
120
+ print(result.observation.echoed_message)
121
+ ```
122
+
123
+ For a detailed quick start, check out the [docs page](https://meta-pytorch.org/OpenEnv/quickstart/).
124
+
52
125
  ## OpenEnv on partner platforms:
53
126
 
54
127
  - [Lightning AI Studio](https://lightning.ai/environments?section=featured)
55
- - [TRL example](https://huggingface.co/docs/trl/main/en/openenv)
128
+ - [TRL example](https://huggingface.co/docs/trl/openenv)
56
129
  - [Unsloth Google Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/OpenEnv_gpt_oss_(20B)_Reinforcement_Learning_2048_Game.ipynb)
57
130
  - [ART example](https://art.openpipe.ai/integrations/openenv-integration)
58
131
  - [Oumi example](https://github.com/oumi-ai/oumi/blob/main/notebooks/Oumi%20-%20OpenEnv%20GRPO%20with%20trl.ipynb)
@@ -77,6 +150,10 @@ The OpenEnv CLI (`openenv`) provides commands to initialize new environments and
77
150
  Below is a list of active and historical RFCs for OpenEnv. RFCs are proposals for major changes or features. Please review and contribute!
78
151
 
79
152
  - [RFC 001: Baseline API and Interface Specifications](https://github.com/meta-pytorch/OpenEnv/pull/26)
153
+ - [RFC 002: Discoverability of environment tools by agents](https://github.com/meta-pytorch/OpenEnv/pull/32)
154
+ - [RFC 003: Add MCP (Model Context Protocol) support](https://github.com/meta-pytorch/OpenEnv/pull/224)
155
+ - [RFC 004: Add delayed rewards support for trajectory-based scoring](https://github.com/meta-pytorch/OpenEnv/pull/337)
156
+ - [RFC 005: Agentic Harness Integration](https://github.com/meta-pytorch/OpenEnv/pull/387)
80
157
 
81
158
  ## Architecture
82
159
 
@@ -87,10 +164,10 @@ Below is a list of active and historical RFCs for OpenEnv. RFCs are proposals fo
87
164
  │ Client Application │
88
165
  │ ┌────────────────┐ ┌──────────────────┐ │
89
166
  │ │ EchoEnv │ │ CodingEnv │ │
90
- │ │ (HTTPEnvClient)│ │ (HTTPEnvClient) │ │
167
+ │ │ (EnvClient) │ │ (EnvClient) │ │
91
168
  │ └────────┬───────┘ └────────┬─────────┘ │
92
169
  └───────────┼───────────────────────────────┼─────────────┘
93
- │ HTTP │ HTTP
170
+ │ WebSocket │ WebSocket
94
171
  │ (reset, step, state) │
95
172
  ┌───────────▼───────────────────────────────▼─────────────┐
96
173
  │ Docker Containers (Isolated) │
@@ -137,9 +214,11 @@ Base class for implementing environment logic:
137
214
  - **`step(action)`**: Execute an `Action`, returns resulting `Observation`
138
215
  - **`state()`**: Access episode metadata (`State` with episode_id, step_count, etc.)
139
216
 
140
- #### 3. HTTPEnvClient (Client-Side)
141
- Base class for HTTP communication:
142
- - Handles HTTP requests to environment server
217
+ #### 3. EnvClient (Client-Side)
218
+ Base class for environment communication:
219
+ - **Async by default**: Use `async with` and `await` for all operations
220
+ - **Sync wrapper**: Call `.sync()` to get a `SyncEnvClient` for synchronous usage
221
+ - Handles WebSocket connections to environment server
143
222
  - Contains a utility to spin up a docker container locally for the corresponding environment
144
223
  - Type-safe action/observation parsing
145
224
 
@@ -172,7 +251,7 @@ my_env/
172
251
  ├── .dockerignore # Docker build exclusions
173
252
  ├── __init__.py # Export YourAction, YourObservation, YourEnv
174
253
  ├── models.py # Define Action, Observation, State dataclasses
175
- ├── client.py # Implement YourEnv(HTTPEnvClient)
254
+ ├── client.py # Implement YourEnv(EnvClient)
176
255
  ├── README.md # Document your environment
177
256
  ├── openenv.yaml # Environment manifest
178
257
  ├── pyproject.toml # Dependencies and package configuration
@@ -219,10 +298,23 @@ See [`envs/README.md`](envs/README.md) for a complete guide on building environm
219
298
  ### For Environment Users
220
299
 
221
300
  To use an environment:
222
- 1. Import from `envs.your_env`: `from envs.echo_env import EchoAction, EchoEnv`
223
- 2. Create client: `client = EchoEnv.from_docker_image("echo-env:latest")`
224
- 3. Interact: `client.reset()`, `client.step(action)`, `client.state()`
225
- 4. Cleanup: `client.close()`
301
+ 1. Install the client: `pip install git+https://huggingface.co/spaces/openenv/echo-env`
302
+ 2. Import: `from echo_env import EchoAction, EchoEnv`
303
+ 3. Use async (recommended) or sync API:
304
+
305
+ **Async (recommended):**
306
+ ```python
307
+ async with EchoEnv(base_url="...") as client:
308
+ result = await client.reset()
309
+ result = await client.step(action)
310
+ ```
311
+
312
+ **Sync (via `.sync()` wrapper):**
313
+ ```python
314
+ with EchoEnv(base_url="...").sync() as client:
315
+ result = client.reset()
316
+ result = client.step(action)
317
+ ```
226
318
 
227
319
  See example scripts in `examples/` directory.
228
320
 
@@ -253,37 +345,56 @@ For detailed options: `openenv init --help` and `openenv push --help`.
253
345
  3. **Container Isolation**: Each environment runs in its own container
254
346
  4. **Simple APIs**: Minimal, intuitive interfaces
255
347
 
256
- ## Quick Start
348
+ ## Development
257
349
 
258
- ### Using the Echo Environment(Example)
350
+ ### Installation
259
351
 
260
- ```python
261
- from envs.echo_env import EchoAction, EchoEnv
352
+ ```bash
353
+ # Clone the repository
354
+ git clone https://github.com/meta-pytorch/OpenEnv.git
355
+ cd OpenEnv
356
+
357
+ # Install core package in editable mode
358
+ pip install -e .
359
+ # Or using uv (faster)
360
+ uv pip install -e .
361
+ ```
362
+
363
+ ### Running Tests
262
364
 
263
- # Automatically start container and connect
264
- client = EchoEnv.from_docker_image("echo-env:latest")
365
+ OpenEnv uses a modular dependency structure: the core package is minimal, and each environment has its own dependencies. This means some tests require environment-specific packages.
265
366
 
266
- # Reset the environment
267
- result = client.reset()
268
- print(result.observation.echoed_message) # "Echo environment ready!"
367
+ ```bash
368
+ # Install pytest (required for running tests)
369
+ uv pip install pytest
269
370
 
270
- # Send messages
271
- result = client.step(EchoAction(message="Hello, World!"))
272
- print(result.observation.echoed_message) # "Hello, World!"
273
- print(result.reward) # 1.3 (based on message length)
371
+ # Run all tests (skips tests requiring uninstalled dependencies)
372
+ PYTHONPATH=src:envs uv run pytest tests/ -v --tb=short
274
373
 
275
- # Cleanup
276
- client.close() # Stops and removes container
374
+ # Run a specific test file
375
+ PYTHONPATH=src:envs uv run pytest tests/envs/test_echo_environment.py -v
277
376
  ```
278
377
 
378
+ **To run environment-specific tests**, install that environment's dependencies:
379
+
380
+ ```bash
381
+ # Example: Install coding_env with dev dependencies (includes smolagents + pytest)
382
+ uv pip install -e "envs/coding_env[dev]"
383
+
384
+ # Then run coding_env tests
385
+ PYTHONPATH=src:envs uv run pytest tests/envs/test_python_codeact_rewards.py -v
386
+ ```
387
+
388
+ Tests will be automatically skipped if their required dependencies aren't installed.
389
+
279
390
  ## Requirements
280
391
 
281
- - Python 3.11+
392
+ - Python 3.10+
282
393
  - Docker Desktop or Docker Engine
283
394
  - FastAPI >= 0.104.0
284
395
  - Uvicorn >= 0.24.0
285
396
  - Requests >= 2.25.0
286
- - smolagents (for coding environment)
397
+ - Environment-specific dependencies (e.g., smolagents for coding_env)
287
398
 
288
399
  ## Supported RL Tools
289
400
  The goal of this project is to support a broad set of open and closed tools to help standardize the agentic RL community. If you have a project that supports OpenEnv environments, please put up a PR to add your tool name along with a link to your documentation.
@@ -292,7 +403,7 @@ The goal of this project is to support a broad set of open and closed tools to h
292
403
  See GRPO BlackJack training example: [`examples/grpo_blackjack/`](examples/grpo_blackjack/)
293
404
 
294
405
  ### TRL
295
- See the [TRL example](https://huggingface.co/docs/trl/main/en/openenv) on how to integrate OpenEnv environments with GRPO training.
406
+ See the [TRL example](https://huggingface.co/docs/trl/openenv) on how to integrate OpenEnv environments with GRPO training.
296
407
 
297
408
  ### Unsloth
298
409
  See the 2048 game example based on gpt-oss: [Colab notebook](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/OpenEnv_gpt_oss_(20B)_Reinforcement_Learning_2048_Game.ipynb)
@@ -308,27 +419,20 @@ See the [Oumi example](https://github.com/oumi-ai/oumi/blob/main/notebooks/Oumi%
308
419
 
309
420
  ## Example Environments
310
421
 
311
- ### Echo Environment
312
- A simple environment that echoes back messages with metadata. Perfect for:
313
- - Testing the HTTP server infrastructure
314
- - Learning the framework basics
315
- - Verifying container deployment
316
-
317
- See: [`envs/echo_env/README.md`](envs/echo_env/README.md)
318
-
319
- ### Coding Environment
320
- Executes arbitrary Python code in a sandboxed environment. Features:
321
- - Safe code execution using smolagents
322
- - Capture stdout, stderr, and exit codes
323
- - Persistent execution context within episodes
324
- - Error handling with detailed messages
422
+ | Environment | Description |
423
+ |---|---|
424
+ | [Echo Environment](envs/echo_env/README.md) | Echoes back messages with metadata. Ideal for testing HTTP server infrastructure, learning framework basics, and verifying container deployment. |
425
+ | [Coding Environment](envs/coding_env/README.md) | Sandboxed Python code execution via smolagents. Captures stdout/stderr/exit codes, supports persistent episode context, and provides detailed error handling. |
426
+ | [Chess Environment](envs/chess_env/README.md) | Chess RL environment with configurable opponents and full rules support. |
427
+ | [Atari Environment](envs/atari_env/README.md) | Classic Arcade Learning Environment tasks for RL benchmarking. |
428
+ | [FinRL Environment](envs/finrl_env/README.md) | Financial market simulations for algorithmic trading experiments. |
325
429
 
326
- See: [`envs/coding_env/README.md`](envs/coding_env/README.md)
430
+ > Browse the full catalog of community environments at [meta-pytorch.org/OpenEnv/environments](https://meta-pytorch.org/OpenEnv/environments/).
327
431
 
328
432
  ## Community Support & Acknowledgments
329
433
  This is an open and community-centric project. If you would like to add your name here, please put up a pull request and tag @jspisak for review. Ty!!
330
434
 
331
- Supporters include: Meta-PyTorch, Hugging Face, [Patronus AI](https://patronus.ai), [Surge AI](https://surgehq.ai), [LastMile AI](https://www.lastmileai.dev), Unsloth AI, Reflection AI, vLLM, SkyRL (UC-Berkeley), LightningAI, Axolotl AI, Stanford Scaling Intelligence Lab, Mithril, [OpenMined](https://openmined.org/), [Fleet AI](https://fleetai.com), [Halluminate](https://halluminate.ai/), [Turing](https://www.turing.com/) ..
435
+ Supporters include: Meta-PyTorch, Hugging Face, [Scaler AI Labs](https://scalerailabs.com), [Patronus AI](https://patronus.ai), [Surge AI](https://surgehq.ai), [LastMile AI](https://www.lastmileai.dev), Unsloth AI, Reflection AI, vLLM, SkyRL (UC-Berkeley), LightningAI, Axolotl AI, Stanford Scaling Intelligence Lab, Mithril, [OpenMined](https://openmined.org/), [Fleet AI](https://fleetai.com), [Halluminate](https://halluminate.ai/), [Turing](https://www.turing.com/), [Scale AI](https://scale.com/) ..
332
436
 
333
437
  And we'd also like to acknowledge the team at Farama Foundation as the OpenEnv API was heavily inspired by the work you all have done on Gymnasium. Cheers!
334
438
 
@@ -1,41 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: openenv
3
- Version: 0.2.0
4
- Summary: A unified framework for reinforcement learning environments
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- License-File: LICENSE
8
- Requires-Dist: fastapi>=0.104.0
9
- Requires-Dist: pydantic>=2.0.0
10
- Requires-Dist: uvicorn>=0.24.0
11
- Requires-Dist: requests>=2.25.0
12
- Requires-Dist: typer>=0.9.0
13
- Requires-Dist: rich>=13.0.0
14
- Requires-Dist: pyyaml>=6.0
15
- Requires-Dist: huggingface_hub>=0.20.0
16
- Requires-Dist: openai>=2.7.2
17
- Requires-Dist: tomli>=2.3.0
18
- Requires-Dist: tomli-w>=1.2.0
19
- Requires-Dist: websockets>=15.0.1
20
- Provides-Extra: core
21
- Requires-Dist: fastapi>=0.104.0; extra == "core"
22
- Requires-Dist: pydantic>=2.0.0; extra == "core"
23
- Requires-Dist: uvicorn>=0.24.0; extra == "core"
24
- Requires-Dist: requests>=2.25.0; extra == "core"
25
- Requires-Dist: websockets>=15.0.1; extra == "core"
26
- Provides-Extra: cli
27
- Requires-Dist: typer>=0.9.0; extra == "cli"
28
- Requires-Dist: rich>=13.0.0; extra == "cli"
29
- Requires-Dist: pyyaml>=6.0; extra == "cli"
30
- Requires-Dist: huggingface_hub>=0.20.0; extra == "cli"
31
- Requires-Dist: openai>=2.7.2; extra == "cli"
32
- Requires-Dist: tomli>=2.3.0; extra == "cli"
33
- Requires-Dist: tomli-w>=1.2.0; extra == "cli"
34
- Provides-Extra: all
35
- Requires-Dist: openenv[core]; extra == "all"
36
- Requires-Dist: openenv[cli]; extra == "all"
37
- Dynamic: license-file
38
-
39
1
  # <img width="35" height="35" alt="image" src="https://github.com/user-attachments/assets/2700a971-e5d6-4036-b03f-2f89c9791609" /> OpenEnv: Agentic Execution Environments
40
2
 
41
3
  An e2e framework for creating, deploying and using isolated execution environments for agentic RL training, built using Gymnasium style simple APIs.
@@ -49,10 +11,61 @@ An e2e framework for creating, deploying and using isolated execution environmen
49
11
 
50
12
  **🚀 Featured Example:** Train LLMs to play BlackJack using [torchforge](https://github.com/meta-pytorch/torchforge) (PyTorch's agentic RL framework): [`examples/grpo_blackjack/`](examples/grpo_blackjack/)
51
13
 
14
+ **🔥 Zero to Hero Tutorial:** End to end tutorial from our [GPU Mode](tutorial/README.md) lecture and other hackathons.
15
+
16
+ ## Quick Start
17
+
18
+ Install the OpenEnv core package:
19
+
20
+ ```bash
21
+ pip install openenv
22
+ ```
23
+
24
+ Install an environment client (e.g., Echo):
25
+
26
+ ```bash
27
+ pip install git+https://huggingface.co/spaces/openenv/echo_env
28
+ ```
29
+
30
+ Then use the environment:
31
+
32
+ ```python
33
+ import asyncio
34
+ from echo_env import EchoAction, EchoEnv
35
+
36
+ async def main():
37
+ # Connect to a running Space (async context manager)
38
+ async with EchoEnv(base_url="https://openenv-echo-env.hf.space") as client:
39
+ # Reset the environment
40
+ result = await client.reset()
41
+ print(result.observation.echoed_message) # "Echo environment ready!"
42
+
43
+ # Send messages
44
+ result = await client.step(EchoAction(message="Hello, World!"))
45
+ print(result.observation.echoed_message) # "Hello, World!"
46
+ print(result.reward) # 1.3 (based on message length)
47
+
48
+ asyncio.run(main())
49
+ ```
50
+
51
+ **Synchronous usage** is also supported via the `.sync()` wrapper:
52
+
53
+ ```python
54
+ from echo_env import EchoAction, EchoEnv
55
+
56
+ # Use .sync() for synchronous context manager
57
+ with EchoEnv(base_url="https://openenv-echo-env.hf.space").sync() as client:
58
+ result = client.reset()
59
+ result = client.step(EchoAction(message="Hello, World!"))
60
+ print(result.observation.echoed_message)
61
+ ```
62
+
63
+ For a detailed quick start, check out the [docs page](https://meta-pytorch.org/OpenEnv/quickstart/).
64
+
52
65
  ## OpenEnv on partner platforms:
53
66
 
54
67
  - [Lightning AI Studio](https://lightning.ai/environments?section=featured)
55
- - [TRL example](https://huggingface.co/docs/trl/main/en/openenv)
68
+ - [TRL example](https://huggingface.co/docs/trl/openenv)
56
69
  - [Unsloth Google Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/OpenEnv_gpt_oss_(20B)_Reinforcement_Learning_2048_Game.ipynb)
57
70
  - [ART example](https://art.openpipe.ai/integrations/openenv-integration)
58
71
  - [Oumi example](https://github.com/oumi-ai/oumi/blob/main/notebooks/Oumi%20-%20OpenEnv%20GRPO%20with%20trl.ipynb)
@@ -77,6 +90,10 @@ The OpenEnv CLI (`openenv`) provides commands to initialize new environments and
77
90
  Below is a list of active and historical RFCs for OpenEnv. RFCs are proposals for major changes or features. Please review and contribute!
78
91
 
79
92
  - [RFC 001: Baseline API and Interface Specifications](https://github.com/meta-pytorch/OpenEnv/pull/26)
93
+ - [RFC 002: Discoverability of environment tools by agents](https://github.com/meta-pytorch/OpenEnv/pull/32)
94
+ - [RFC 003: Add MCP (Model Context Protocol) support](https://github.com/meta-pytorch/OpenEnv/pull/224)
95
+ - [RFC 004: Add delayed rewards support for trajectory-based scoring](https://github.com/meta-pytorch/OpenEnv/pull/337)
96
+ - [RFC 005: Agentic Harness Integration](https://github.com/meta-pytorch/OpenEnv/pull/387)
80
97
 
81
98
  ## Architecture
82
99
 
@@ -87,10 +104,10 @@ Below is a list of active and historical RFCs for OpenEnv. RFCs are proposals fo
87
104
  │ Client Application │
88
105
  │ ┌────────────────┐ ┌──────────────────┐ │
89
106
  │ │ EchoEnv │ │ CodingEnv │ │
90
- │ │ (HTTPEnvClient)│ │ (HTTPEnvClient) │ │
107
+ │ │ (EnvClient) │ │ (EnvClient) │ │
91
108
  │ └────────┬───────┘ └────────┬─────────┘ │
92
109
  └───────────┼───────────────────────────────┼─────────────┘
93
- │ HTTP │ HTTP
110
+ │ WebSocket │ WebSocket
94
111
  │ (reset, step, state) │
95
112
  ┌───────────▼───────────────────────────────▼─────────────┐
96
113
  │ Docker Containers (Isolated) │
@@ -137,9 +154,11 @@ Base class for implementing environment logic:
137
154
  - **`step(action)`**: Execute an `Action`, returns resulting `Observation`
138
155
  - **`state()`**: Access episode metadata (`State` with episode_id, step_count, etc.)
139
156
 
140
- #### 3. HTTPEnvClient (Client-Side)
141
- Base class for HTTP communication:
142
- - Handles HTTP requests to environment server
157
+ #### 3. EnvClient (Client-Side)
158
+ Base class for environment communication:
159
+ - **Async by default**: Use `async with` and `await` for all operations
160
+ - **Sync wrapper**: Call `.sync()` to get a `SyncEnvClient` for synchronous usage
161
+ - Handles WebSocket connections to environment server
143
162
  - Contains a utility to spin up a docker container locally for the corresponding environment
144
163
  - Type-safe action/observation parsing
145
164
 
@@ -172,7 +191,7 @@ my_env/
172
191
  ├── .dockerignore # Docker build exclusions
173
192
  ├── __init__.py # Export YourAction, YourObservation, YourEnv
174
193
  ├── models.py # Define Action, Observation, State dataclasses
175
- ├── client.py # Implement YourEnv(HTTPEnvClient)
194
+ ├── client.py # Implement YourEnv(EnvClient)
176
195
  ├── README.md # Document your environment
177
196
  ├── openenv.yaml # Environment manifest
178
197
  ├── pyproject.toml # Dependencies and package configuration
@@ -219,10 +238,23 @@ See [`envs/README.md`](envs/README.md) for a complete guide on building environm
219
238
  ### For Environment Users
220
239
 
221
240
  To use an environment:
222
- 1. Import from `envs.your_env`: `from envs.echo_env import EchoAction, EchoEnv`
223
- 2. Create client: `client = EchoEnv.from_docker_image("echo-env:latest")`
224
- 3. Interact: `client.reset()`, `client.step(action)`, `client.state()`
225
- 4. Cleanup: `client.close()`
241
+ 1. Install the client: `pip install git+https://huggingface.co/spaces/openenv/echo-env`
242
+ 2. Import: `from echo_env import EchoAction, EchoEnv`
243
+ 3. Use async (recommended) or sync API:
244
+
245
+ **Async (recommended):**
246
+ ```python
247
+ async with EchoEnv(base_url="...") as client:
248
+ result = await client.reset()
249
+ result = await client.step(action)
250
+ ```
251
+
252
+ **Sync (via `.sync()` wrapper):**
253
+ ```python
254
+ with EchoEnv(base_url="...").sync() as client:
255
+ result = client.reset()
256
+ result = client.step(action)
257
+ ```
226
258
 
227
259
  See example scripts in `examples/` directory.
228
260
 
@@ -253,37 +285,56 @@ For detailed options: `openenv init --help` and `openenv push --help`.
253
285
  3. **Container Isolation**: Each environment runs in its own container
254
286
  4. **Simple APIs**: Minimal, intuitive interfaces
255
287
 
256
- ## Quick Start
288
+ ## Development
257
289
 
258
- ### Using the Echo Environment(Example)
290
+ ### Installation
259
291
 
260
- ```python
261
- from envs.echo_env import EchoAction, EchoEnv
292
+ ```bash
293
+ # Clone the repository
294
+ git clone https://github.com/meta-pytorch/OpenEnv.git
295
+ cd OpenEnv
262
296
 
263
- # Automatically start container and connect
264
- client = EchoEnv.from_docker_image("echo-env:latest")
297
+ # Install core package in editable mode
298
+ pip install -e .
299
+ # Or using uv (faster)
300
+ uv pip install -e .
301
+ ```
265
302
 
266
- # Reset the environment
267
- result = client.reset()
268
- print(result.observation.echoed_message) # "Echo environment ready!"
303
+ ### Running Tests
269
304
 
270
- # Send messages
271
- result = client.step(EchoAction(message="Hello, World!"))
272
- print(result.observation.echoed_message) # "Hello, World!"
273
- print(result.reward) # 1.3 (based on message length)
305
+ OpenEnv uses a modular dependency structure: the core package is minimal, and each environment has its own dependencies. This means some tests require environment-specific packages.
274
306
 
275
- # Cleanup
276
- client.close() # Stops and removes container
307
+ ```bash
308
+ # Install pytest (required for running tests)
309
+ uv pip install pytest
310
+
311
+ # Run all tests (skips tests requiring uninstalled dependencies)
312
+ PYTHONPATH=src:envs uv run pytest tests/ -v --tb=short
313
+
314
+ # Run a specific test file
315
+ PYTHONPATH=src:envs uv run pytest tests/envs/test_echo_environment.py -v
277
316
  ```
278
317
 
318
+ **To run environment-specific tests**, install that environment's dependencies:
319
+
320
+ ```bash
321
+ # Example: Install coding_env with dev dependencies (includes smolagents + pytest)
322
+ uv pip install -e "envs/coding_env[dev]"
323
+
324
+ # Then run coding_env tests
325
+ PYTHONPATH=src:envs uv run pytest tests/envs/test_python_codeact_rewards.py -v
326
+ ```
327
+
328
+ Tests will be automatically skipped if their required dependencies aren't installed.
329
+
279
330
  ## Requirements
280
331
 
281
- - Python 3.11+
332
+ - Python 3.10+
282
333
  - Docker Desktop or Docker Engine
283
334
  - FastAPI >= 0.104.0
284
335
  - Uvicorn >= 0.24.0
285
336
  - Requests >= 2.25.0
286
- - smolagents (for coding environment)
337
+ - Environment-specific dependencies (e.g., smolagents for coding_env)
287
338
 
288
339
  ## Supported RL Tools
289
340
  The goal of this project is to support a broad set of open and closed tools to help standardize the agentic RL community. If you have a project that supports OpenEnv environments, please put up a PR to add your tool name along with a link to your documentation.
@@ -292,7 +343,7 @@ The goal of this project is to support a broad set of open and closed tools to h
292
343
  See GRPO BlackJack training example: [`examples/grpo_blackjack/`](examples/grpo_blackjack/)
293
344
 
294
345
  ### TRL
295
- See the [TRL example](https://huggingface.co/docs/trl/main/en/openenv) on how to integrate OpenEnv environments with GRPO training.
346
+ See the [TRL example](https://huggingface.co/docs/trl/openenv) on how to integrate OpenEnv environments with GRPO training.
296
347
 
297
348
  ### Unsloth
298
349
  See the 2048 game example based on gpt-oss: [Colab notebook](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/OpenEnv_gpt_oss_(20B)_Reinforcement_Learning_2048_Game.ipynb)
@@ -308,27 +359,20 @@ See the [Oumi example](https://github.com/oumi-ai/oumi/blob/main/notebooks/Oumi%
308
359
 
309
360
  ## Example Environments
310
361
 
311
- ### Echo Environment
312
- A simple environment that echoes back messages with metadata. Perfect for:
313
- - Testing the HTTP server infrastructure
314
- - Learning the framework basics
315
- - Verifying container deployment
316
-
317
- See: [`envs/echo_env/README.md`](envs/echo_env/README.md)
318
-
319
- ### Coding Environment
320
- Executes arbitrary Python code in a sandboxed environment. Features:
321
- - Safe code execution using smolagents
322
- - Capture stdout, stderr, and exit codes
323
- - Persistent execution context within episodes
324
- - Error handling with detailed messages
362
+ | Environment | Description |
363
+ |---|---|
364
+ | [Echo Environment](envs/echo_env/README.md) | Echoes back messages with metadata. Ideal for testing HTTP server infrastructure, learning framework basics, and verifying container deployment. |
365
+ | [Coding Environment](envs/coding_env/README.md) | Sandboxed Python code execution via smolagents. Captures stdout/stderr/exit codes, supports persistent episode context, and provides detailed error handling. |
366
+ | [Chess Environment](envs/chess_env/README.md) | Chess RL environment with configurable opponents and full rules support. |
367
+ | [Atari Environment](envs/atari_env/README.md) | Classic Arcade Learning Environment tasks for RL benchmarking. |
368
+ | [FinRL Environment](envs/finrl_env/README.md) | Financial market simulations for algorithmic trading experiments. |
325
369
 
326
- See: [`envs/coding_env/README.md`](envs/coding_env/README.md)
370
+ > Browse the full catalog of community environments at [meta-pytorch.org/OpenEnv/environments](https://meta-pytorch.org/OpenEnv/environments/).
327
371
 
328
372
  ## Community Support & Acknowledgments
329
373
  This is an open and community-centric project. If you would like to add your name here, please put up a pull request and tag @jspisak for review. Ty!!
330
374
 
331
- Supporters include: Meta-PyTorch, Hugging Face, [Patronus AI](https://patronus.ai), [Surge AI](https://surgehq.ai), [LastMile AI](https://www.lastmileai.dev), Unsloth AI, Reflection AI, vLLM, SkyRL (UC-Berkeley), LightningAI, Axolotl AI, Stanford Scaling Intelligence Lab, Mithril, [OpenMined](https://openmined.org/), [Fleet AI](https://fleetai.com), [Halluminate](https://halluminate.ai/), [Turing](https://www.turing.com/) ..
375
+ Supporters include: Meta-PyTorch, Hugging Face, [Scaler AI Labs](https://scalerailabs.com), [Patronus AI](https://patronus.ai), [Surge AI](https://surgehq.ai), [LastMile AI](https://www.lastmileai.dev), Unsloth AI, Reflection AI, vLLM, SkyRL (UC-Berkeley), LightningAI, Axolotl AI, Stanford Scaling Intelligence Lab, Mithril, [OpenMined](https://openmined.org/), [Fleet AI](https://fleetai.com), [Halluminate](https://halluminate.ai/), [Turing](https://www.turing.com/), [Scale AI](https://scale.com/) ..
332
376
 
333
377
  And we'd also like to acknowledge the team at Farama Foundation as the OpenEnv API was heavily inspired by the work you all have done on Gymnasium. Cheers!
334
378