Skip to content

Conversation

@ProKil
Copy link
Collaborator

@ProKil ProKil commented Oct 20, 2025

Summary

This PR implements a comprehensive refactoring of the RealtimeGym package API and adds complete CI/CD infrastructure.

Changes

API Refactoring

  • Environment API: Updated all environments to follow standardized gym pattern:
    • reset() now returns (obs, done)
    • New step(action) method returns (obs, done, reward)
    • Maintained backward compatibility with legacy act() method
  • Agent API: Updated all agents to follow observation-receiving pattern:
    • New observe(observation) method to receive observations
    • Updated think(timeout) signature
    • act() returns None for default action fallback
  • Affected files: base.py, freeway.py, snake.py, overcooked.py, and all agent implementations

Package Structure

  • Added gym-like make() function in __init__.py with environment registry
  • Added lazy imports for agents
  • Updated pyproject.toml with complete dependencies list
  • Added CLI entry point for run_game.py

Code Quality

  • Type Checking: Passes ty check (19/19 files)
  • Linting: Passes ruff check and ruff format
  • Fixed ambiguous variable names (l → descriptive names)
  • Fixed comparison operators (== True, != None)
  • Fixed held_object bug in overcooked.py
  • Added proper type hints throughout

CI/CD Infrastructure

  • .pre-commit-config.yaml: Pre-commit hooks for ruff and ty
  • .github/workflows/pr-checks.yml: GitHub Actions workflow for PR validation
  • CONTRIBUTING.md: Developer contribution guidelines
  • Updated README.md with development setup instructions

Third-Party Code Management

  • Added THIRD_PARTY_NOTICE.md for overcooked_new vendored code
  • Excluded overcooked_new from ty and ruff checks (third-party code from HumanCompatibleAI)
  • Added attribution comments in relevant files

Testing

All checks passing:

  • ✅ Type checking: 19/19 files
  • ✅ Ruff linting: All checks passed
  • ✅ Ruff formatting: All checks passed
  • ✅ Pre-commit hooks: All hooks passed

Backward Compatibility

Legacy act() method maintained in environments for backward compatibility with existing code.

Major Changes:
- Refactor environment API to follow standard gym pattern (reset/step)
- Refactor agent API to use observe/think/act pattern
- Add ty type checking with configuration
- Add ruff linting with configuration
- Set up pre-commit hooks
- Add GitHub Actions workflow for PR checks
- Add third-party code notices for overcooked_new
- Update all environments (Freeway, Snake, Overcooked)
- Update all agents (Reactive, Planning, Agile)
- Maintain backward compatibility

New Features:
- gym-like make() API for easy environment creation
- Standardized obs, done = env.reset() pattern
- Standardized obs, done, reward = env.step(action) pattern
- agent.observe(obs) / agent.think(timeout) / agent.act() pattern
- Type checking with ty (all checks pass)
- Linting with ruff (all checks pass)
- Pre-commit hooks for automated quality checks
- CI/CD pipeline for PR validation

Documentation:
- Updated README.md with development setup
- Added CONTRIBUTING.md with contribution guidelines
- Added THIRD_PARTY_NOTICE.md for Overcooked-AI code
- Added inline documentation and comments
- Updated ruff-pre-commit from v0.8.4 to v0.14.1
- Fixes issue where pre-commit ruff (v0.8.4) was undoing standalone ruff (v0.11.13) formatting
- Both versions now agree on formatting style
- Added ty to dev dependencies in pyproject.toml
- Fixes 'ty: No such file or directory' error in GitHub Actions
- CI workflow uses 'uv sync --all-extras' to install dev dependencies
@ProKil ProKil requested a review from wenyl22 October 21, 2025 00:00
@wenyl22 wenyl22 merged commit ba262ed into main Oct 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants