[PATCH] Deprecate HTTP in websockets#252
Conversation
…erver capabilities - Introduced WebSocketEnvClient for persistent sessions with multi-step interactions. - Updated HTTPEnvServer to support WebSocket connections and manage multiple concurrent environments. - Added WebSocket message types and responses for better communication. - Enhanced Environment interface with concurrency safety attributes.
…d WSIncomingMessage
- Genericize `Environment`, `HTTPEnvClient`, and `WebSocketEnvClient` with `ActT`, `ObsT`, and `StateT` to improve type inference in IDEs. - Update client methods to use `Dict[str, Any]` for stricter typing of JSON payloads. - Remove conditional `websockets` import in `ws_env_client.py` and simplify connection logic. - Fix async method detection in `HTTPEnvServer` to correctly handle factory functions and avoid unnecessary instantiation duringRefactor core types for better inference and fix async detection - Genericize `Environment`, `HTTPEnvClient`, and `WebSocketEnvClient` with `ActT`, `ObsT`, and `StateT` to improve type inference in IDEs. - Update client methods to use `Dict[str, Any]` for stricter typing of JSON payloads. - Remove conditional `websockets` import in `ws_env_client.py` and simplify connection logic. - Fix async method detection in `HTTPEnvServer` to correctly handle factory functions and avoid unnecessary instantiation during
…ty function for URL conversion
|
This is Claude's review for this one: Pull Request #252 ReviewSummaryThis PR deprecates the HTTP client in favor of WebSocket-only communication, renaming Overall Assessment: Good direction, but broken - all environment clients will crash on import. Critical Issues1. All Environment Clients Still Import Deleted
|
| Environment | Broken Import |
|---|---|
| envs/echo_env/client.py:21 | from openenv.core.http_env_client import HTTPEnvClient |
| envs/atari_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/browsergym_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/chat_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/coding_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/connect4_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/dipg_safety_env/client.py | from openenv.core.http_env_client import HTTPEnvClient |
| envs/finrl_env/client.py | (likely same) |
| envs/git_env/client.py | (likely same) |
| envs/openspiel_env/client.py | (likely same) |
| envs/sumo_rl_env/client.py | (likely same) |
| envs/textarena_env/client.py | (likely same) |
Required Fix for each client:
# Before (broken)
from openenv.core.http_env_client import HTTPEnvClient
class EchoEnv(HTTPEnvClient[EchoAction, EchoObservation]):
...
# After (fixed)
from openenv.core.env_client import EnvClient
class EchoEnv(EnvClient[EchoAction, EchoObservation]):
...2. StepResult Import Also Broken
Severity: CRITICAL
Some clients import StepResult from the deleted file:
# browsergym_env/client.py, dipg_safety_env/client.py
from openenv.core.http_env_client import HTTPEnvClient, StepResultStepResult should be imported from openenv.core.client_types instead.
3. Docstrings Still Reference HTTP
Severity: MINOR - Cosmetic but confusing
"""
Echo Environment HTTP Client.
This module provides the client for connecting to an Echo Environment server
over HTTP.
"""Should be updated to reflect WebSocket-based communication.
Similarly, server app.py files have docstrings mentioning HTTPEnvClient compatibility.
What's Done Correctly
ws_env_client.py→env_client.pyrename is cleanWebSocketEnvClient→EnvClientsimplifies the API- The new
EnvClientclass is well-documented - HTTP URL auto-conversion to WS is preserved (
convert_to_ws_url)
Action Items
- CRITICAL: Update all 12 environment clients to use
EnvClientinstead ofHTTPEnvClient - CRITICAL: Fix
StepResultimports in browsergym_env and dipg_safety_env - Update client docstrings to remove HTTP references
- Update server app.py docstrings to remove
HTTPEnvClientreferences - Verify CLI templates use the new
EnvClient(checksrc/openenv/cli/templates/) - Add a simple test that imports each client to catch this in CI
Suggested Workflow
Since this PR targets PR #239 (not main), I'd suggest:
- Merge PR [FEATURE] WebSocket-based Concurrency Architecture #239 first (after fixing its issues)
- Then update PR [PATCH] Deprecate HTTP in websockets #252 to fix all the client imports
- Or: fold the HTTP deprecation into PR [FEATURE] WebSocket-based Concurrency Architecture #239 directly to avoid the intermediate broken state
Review Decision
REQUEST_CHANGES - The PR will break every environment client on import. All clients must be updated to use the new EnvClient before this can be merged.
This PR targets #239 and removes the http client.