Traditional query optimizers are static — they were tuned once and never learn from what actually happens in production. We built an autonomous Database Reliability Engineer (DBRE) agent that doesn't just fix slow queries, it gets smarter over time. The agent observes slow PostgreSQL queries via EXPLAIN ANALYZE, takes actions (rewrite query, add index, change join order), and gets scored by 4 independent reward functions — correctness, efficiency, style, and anticheat. Using TRL's GRPO algorithm with 4-bit QLoRA on Qwen2.5-Coder-1.5B, the agent trained from a peak reward of 0.02 to 0.477 across 350 steps. The self-improvement layer is what makes it unique. A Meta Agent watches every 5 episodes, generates code diffs to rewrite the agent's own diagnostic playbook, and an ELO system picks the winner — autonomously evolving from v1 (ELO 984) to v3 (ELO 1016) without any human intervention. Built in 23 hours at the Meta PyTorch OpenEnv Hackathon Grand Finale, Scaler School of Technology, Bangalore. Survived 6 Docker runtime errors, a Colab credit wipeout, and a laptop that stopped charging at 25% battery during training.
Built With
- docker
- fastapi
- fixes-them
- gradio
- grpo
- huggingface
- postgresql
- pydantic
- python
- pytorch
- qlora
- trl
- unsloth