Stop Re-Running Flaky CI Tests: We Built an Open-Source AI Agent to Fix the Root Cause
Every software engineer knows the sinking feeling of opening a pull request, waiting 25 minutes for CI to run, only to see a big red ❌ Failed badge. You check the error log, and it’s a test completely unrelated to your
Every software engineer knows the sinking feeling of opening a pull request, waiting 25 minutes for CI to run, only to see a big red ❌ Failed badge.
You check the error log, and it’s a test completely unrelated to your code changes.
You sigh, hit "Re-run failed jobs", and 20 minutes later... it turns green. ✅ Passed.
It was a flaky test.
According to developer surveys, engineering teams lose 10% to 15% of their weekly velocity rerunning builds, debugging race conditions, and investigating false-alarm failures. Even worse, developers develop "test numbness"—they start ignoring red checks, which is how critical regressions silently slip into production.
Existing tools either:
- Just alert you that a test is flaky (leaving you to spend 3 hours debugging it).
- Blindly retry the test 3 times (masking the underlying race condition and bloating your cloud bill).
We decided to solve the actual root cause. We built [FlakeHealer](https://github.com/vinayakgangan14/flake-healer)—an open-source autonomous agent that reproduces race conditions under stress, generates deterministic patches with AI, and verifies them through a 100-run crucible before submitting a pull request.
⚡ Why Do Tests Flake in CI?
Tests rarely flake because of syntax errors. They flake because of non-deterministic execution environments:
- Timing Windows & Micro-Latencies: A background job finishes in 15ms locally, but takes 35ms when GitHub Actions or AWS runners are under heavy CPU load.
-
Asynchronous Race Conditions: Missing
awaitstatements, unhandled promise resolutions, or reading state before a background worker writes it. - Shared Mutable State: Leaked database transactions, un-cleared mocks, or singleton contamination leaking across test boundaries.
-
Positional Assumptions: Assuming an event or network response will always arrive at
calls[0]instead of matching it dynamically by its attributes.
🛠️ How FlakeHealer Works
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.