An OpenEnv reinforcement learning environment where AI agents learn to debug broken Python code using deterministic, reproducible evaluation.
BugLab is a real-world RL environment where agents fix broken Python code. Features:
- β 30+ debugging problems across 8 error categories
- β 3 explicit tasks (easy β hard difficulty progression)
- β Deterministic dual reward: 70% test pass rate + 30% code quality
- β Multi-step learning: 3 attempts per problem with progress signals
- β Intelligent hints: Category-specific guidance to accelerate agent learning
- β Partial credit system: Reward for progressively passing tests (not all-or-nothing)
- β Rich error feedback: Detailed test failures and suggestions for common mistakes
- β Fully OpenEnv compliant with type validation
- β Reproducible grading - no API calls, no randomness
- β Production ready - deployed on HuggingFace Spaces
git clone https://github.com/Someone-9791/BugLab.git
cd BugLab
pip install -r requirements.txt# Start FastAPI server (for API access)
uvicorn server.app:app --host 0.0.0.0 --port 8000
# In another terminal, run baseline
export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
export HF_TOKEN=your_hf_token
python inference.pyFor local testing with a visual web interface:
# Start Gradio UI
python -m server.gradio_ui
# Visit http://localhost:7860 in your browserNote: The HuggingFace Space runs the API server (not the UI) to enable automated agent evaluation. The Gradio UI is for local manual testing only.
docker build -t buglab .
docker run -p 8000:8000 \
-e API_BASE_URL=https://router.huggingface.co/v1 \
-e MODEL_NAME=Qwen/Qwen2.5-72B-Instruct \
-e HF_TOKEN=your_token \
buglab| Task | Difficulty | Objective | Examples |
|---|---|---|---|
fix_logic_bug |
EasyβMedium | Fix logic errors and operators | Wrong comparison, off-by-one, missing edge cases |
fix_algorithm_bug |
MediumβHard | Fix algorithmic errors | Type errors, wrong returns, recursion bugs |
optimize_and_fix |
Hard | Fix complex bugs + optimize | Performance issues, nested logic, multiple bugs |
Dual Reward System (Deterministic & Reproducible):
- Test Score (70%): Automated test execution - partial credit for passing subset of tests
- Quality Score (30%): Static code analysis (AST) - 6 quality checks
- Progress Bonus: Multi-step rewards for improvement
- Category Hints: Agents receive targeted guidance based on error category
- Error Details: Comprehensive feedback on test failures with input/output/error information
final_reward = (0.7 Γ test_score) + (0.3 Γ quality_score) + improvement_bonus
clamped to [0.0, 1.0]
where test_score = passed_tests / total_tests (rewards partial progress)
Evaluated with Qwen/Qwen2.5-72B-Instruct (temperature=0.0, deterministic):
| Metric | Result |
|---|---|
| Overall Reward | 0.678 |
| Success Rate | 40% |
| Easy Tasks | 83.0% |
| Medium Tasks | 64.2% |
| Hard Tasks | 44.5% |
| Runtime | < 5 minutes (2 vCPU, 8GB RAM) |
Agents earn rewards for progressive improvement, not just all-or-nothing success. Passing 3/5 tests yields reward proportional to progress.
- Category-specific hints guide debugging strategy
- Detailed error messages show failed tests, expected vs. actual output
- Rich observation includes pass/fail counts and suggestions
- Timeout protection (30s) prevents hanging
- Concurrent-safe request handling
- Graceful error handling with 400-level responses
BugLab exposes a simple REST API:
# Reset: get a new debugging problem
curl -X POST http://localhost:8000/reset \
-d '{"task_id": "fix_logic_bug"}'
# Step: submit fixed code and get reward
curl -X POST http://localhost:8000/step \
-d '{"fixed_code": "fixed code here"}'
# State: get current episode state
curl -X GET http://localhost:8000/stateFull API documentation: See server/app.py
BugLab/
βββ server/ # FastAPI backend
β βββ app.py # REST API endpoints (/reset, /step, /state)
β βββ environment.py # OpenEnv implementation
β βββ grader.py # Deterministic grading engine
βββ models.py # Type definitions (Pydantic)
βββ bug_bank.py # 30+ debugging problems
βββ inference.py # Baseline agent evaluation script
βββ openenv.yaml # OpenEnv specification
βββ Dockerfile # Docker container config
βββ requirements.txt # Python dependencies
βββ ARCHITECTURE.md # Detailed technical documentation
β OpenEnv Compliant β Full specification implemented (reset, step, state, type validation)
β Deterministic & Reproducible β No randomness in grading; baseline achieves 67.8% average reward
β Production Ready β Handles concurrent requests, 30s timeout protection, graceful error responses
β Live Deployment β Running on HuggingFace Spaces with Docker containerization
Team Name: Team "Not Found"
| Role | Name |
|---|---|
| π¨βπ» Main Developer | Pranatpal Sharma |
| π©βπΌ Team Leader | Shloka Chourasia |
| π¨ UI/UX Developer | Vedant Sharma |
- License: MIT
- Framework: OpenEnv (Meta/PyTorch)
- Challenge: OpenEnv Hackathon 2026
See LICENSE for details. For security issues, see SECURITY.md.
- ARCHITECTURE.md β Complete technical reference (systems, APIs, task definitions)
- CONTRIBUTING.md β Contribution guidelines
- LICENSE β MIT license