Skip to content

Conversation

Copy link

Copilot AI commented Jan 13, 2026

Addresses automated review feedback on PR #161 identifying type safety, reproducibility, and security issues in the NLE environment implementation.

Critical Fixes

Episode ID initialization

  • Initialize _episode_id in __init__ instead of waiting for reset()
  • Prevents None values if state property accessed before first reset
  • Extract generation logic to _generate_episode_id() to eliminate duplication

Dependency pinning

  • Pin gym==0.26.2 in Dockerfile for API compatibility
  • Handles both old gym API (reset() returns obs) and new API (reset() returns tuple)

Docker build security

  • Add .dockerignore to exclude .git/, venv/, __pycache__, test files from build context

Documentation & Code Quality

  • Remove "beefy compute" assumptions from code and docs (non-standard terminology not in PRINCIPLES.md)
  • Document HTTP-based implementation and future WebSocket migration path
  • Add explanation for why NLEObservation fields are optional (configurable observation space)
  • Remove hardcoded absolute paths from Docker build instructions

Note on Generic Types

Review flagged missing generic type parameters on Environment class. Investigation shows base Environment class is not generic and no existing environments use generics—appears to be review misunderstanding rather than actual invariant.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Jan 13, 2026
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 13, 2026
Copilot AI and others added 2 commits January 13, 2026 02:41
…erignore, remove "beefy compute" references

Co-authored-by: Darktex <890615+Darktex@users.noreply.github.com>
…ability

Co-authored-by: Darktex <890615+Darktex@users.noreply.github.com>
Copilot AI changed the title [WIP] Update feedback on NLE environment implementation in OpenEnv Address critical review feedback: fix episode ID initialization, pin dependencies, improve documentation Jan 13, 2026
Copilot AI requested a review from Darktex January 13, 2026 02:45
@zkwentz
Copy link
Contributor

zkwentz commented Jan 21, 2026

@greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This PR successfully addresses critical feedback from the automated review of PR #161. The changes improve type safety, reproducibility, and code quality:

  • Episode ID fix: Initialized _episode_id in __init__() to prevent None values if state property is accessed before first reset(). Extracted episode ID generation to _generate_episode_id() method to eliminate duplication between __init__ and reset().
  • Dependency pinning: Pinned gym==0.26.2 in Dockerfile for reproducibility and to ensure consistent API behavior across deployments.
  • Build security: Added .dockerignore to exclude .git/, venv/, __pycache__, and test files from Docker build context, reducing image size and preventing sensitive files from being copied.
  • Documentation improvements: Removed non-standard "beefy compute" terminology, added HTTP implementation note with WebSocket migration path, documented why NLEObservation fields are optional (configurable observation space), and removed hardcoded absolute paths.

All changes are focused and appropriate, addressing the specific issues identified without introducing unnecessary modifications.

Confidence Score: 5/5

  • This PR is safe to merge with no blocking issues
  • All changes are well-scoped, properly implemented, and directly address the identified issues. The episode ID initialization fix prevents potential None value bugs, dependency pinning ensures reproducibility, and the .dockerignore addition improves security and build efficiency. Documentation changes accurately reflect the implementation without introducing errors.
  • No files require special attention

Important Files Changed

Filename Overview
.dockerignore Added comprehensive .dockerignore to exclude unnecessary files from Docker build context
src/envs/nle_env/server/Dockerfile Pinned gym version to 0.26.2 for reproducibility and API compatibility
src/envs/nle_env/server/nle_environment.py Fixed episode ID initialization and extracted generation logic to eliminate duplication

Sequence Diagram

sequenceDiagram
    participant Client as NLEEnv Client
    participant Server as FastAPI Server
    participant Env as NLEEnvironment
    participant NLE as NLE Gym Env

    Note over Client,NLE: Episode Initialization
    Client->>Server: POST /reset
    Server->>Env: reset()
    Env->>Env: _generate_episode_id()
    Note over Env: Initialize _episode_id in __init__<br/>and regenerate on reset()
    Env->>NLE: reset()
    NLE-->>Env: gym_obs (dict or tuple)
    Env->>Env: _convert_observation(gym_obs)
    Note over Env: Convert numpy arrays to lists<br/>for JSON serialization
    Env-->>Server: NLEObservation
    Server-->>Client: JSON response

    Note over Client,NLE: Action Execution
    Client->>Server: POST /step {action_id: 0}
    Server->>Env: step(NLEAction)
    Env->>NLE: step(action_id)
    NLE-->>Env: (obs, reward, done, info) or<br/>(obs, reward, terminated, truncated, info)
    Note over Env: Handle both gym 0.25<br/>and 0.26+ API formats
    Env->>Env: Update _step_count, _last_reward, etc.
    Env->>Env: _convert_observation(gym_obs)
    Env-->>Server: NLEObservation
    Server-->>Client: JSON response

    Note over Client,NLE: State Query
    Client->>Server: GET /state
    Server->>Env: state property
    Env-->>Server: NLEState
    Server-->>Client: JSON response
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants