How microsoft/debug-gym works
Step 1. Identify the Main Project Components:
• Environment (debug_gym/gym):
– Contains submodules such as envs (with specific environments like aider, mini_nightmare, and swe_bench), terminal, and tools (e.g., pdb, listdir, eval, rewrite).
– Represents the simulation side that takes code repositories and allows iterative interactions (reset/step) with agents.
• Agents (debug_gym/agents):
– Includes various agent implementations (debug_agent, rewrite_agent, debug_5_agent) that interact with the environment.
– Leverages different tools for executing actions and interpreting observations.
• Analysis & Data:
– The “analysis” directory holds scripts (figure_*.py and gather_results.py) for processing or visualizing experimental results.
– The “data” directory stores benchmark repositories and configurations (mini_nightmare, pytorch, etc.) used for illustration and testing.
• Auxiliary and Support Components:
– “scripts” directory for YAML configuration files and the run.py entrypoint for launching agents with specific benchmarks.
– “tests” directory contains unit and integration tests, ensuring each component (agents, gym environment, and tools) works correctly.
– CI/CD setups are visible via the “.github/workflows” directory, which manage code formatting, testing, and code analysis.
– Configuration management (pyproject.toml, requirements.txt) and tool config files (e.g., pre-commit configuration) support development and deployment.
Step 2. Outline Relationships and Interactions:
• Under “Gym Environment”, further subdivide into:
– Env’s “envs” module (with key environments like RepoEnv, mini_nightmare, swe_bench).
– “Terminal” module responsible for executing code and returning test results.
– “Tools” module containing separate tools (pdb, listdir, view, eval, rewrite) that extend the environment’s capabilities.
• Under “Agents”, list the distinct agent types (e.g., debug_agent, rewrite_agent) and note that these rely on the environment to receive observations and issue commands.
• Auxiliary components such as “Scripts/Configs” (scripts) and “Tests” (tests) connected to the main modules to highlight development and quality assurance practices.
Step 3. Emphasize Architectural Patterns and Design Principles:
• That the environment follows the Gymnasium paradigm (with reset/step interactions).
• Modular design: dynamic tool integration allows new modules to be imported, which augments the agent’s action and observation spaces.
• Denote the loose coupling between agents and environment, as agents query for information and then issue commands based on the evolving state.
• Point out extensibility; for instance, new tools or agents can be added without major changes to the existing framework.
Step 4. Include Relevant Technologies and Frameworks:
• That the project runs on Python≥3.12.
• Use of Gymnasium concepts within the simulation environment.
• Integration of CI/CD tools (GitHub workflows: codeql, formatter, tests) which ensure quality.
• Mention configuration management via YAML files and the use of PyPI for package management.
• Optionally, annotate where LLM-based interactions occur, since agents rely on large language models via llm_api and external services.
• Use clear labels and consistent naming for each major module:
– Label “Gym Environment”, “Agents”, “Data/Benchmarks”, “Scripts/Configs”, “Tests”, and “CI/CD”.
– From Agents → Gym Environment (command/response cycle).
– From Environment → Tools (invocation of discrete functionalities).
– From Environment → Benchmarks (to simulate code repositories) and vice versa.
• Be detailed:
– Break down each module into sub-components if possible.
• Configuration points (e.g., wherein the LLM setup is defined via llm.yaml) and interact with the CLI entry point (scripts/run.py) which ties the system together.
Step 6. Final Touches:
• That each component is clearly referenced from the file tree and the README’s provided system design section.
• To include both “internal” (agents and gym modules) and “external” (benchmarks, CI/CD pipelines) elements to cover all aspects of the system.