Stop Rerunning: An AI Agent That Tells You Which CI Failures Actually Matter

TL;DR — I built an AI agent that fetches GitHub Actions run history, parses CI logs, and classifies each failure as a real bug, a flaky test, or infrastructure noise. Ran it against 21 open-source repos across 12 test frameworks and 5 languages. A local 9B model classified everything as flaky. A cloud model found 56 real bugs hiding inside those "flaky" classifications — tests that fail the same way every single run. Total cloud cost: $0.22.
The Painful Truth
You know the drill. CI goes red. You glance at it. "Probably flaky." You hit rerun. It passes. You merge.
Do that 10 times a day and here's what happens: a red build stops meaning "something is broken." It starts meaning "maybe something is broken, who knows." Engineers merge past red builds. Real regressions slip into production. And nobody notices because the CI signal is already noise.
The research backs this up. Developers spend at least 2.5% of their productive time dealing with flaky tests — 1.1% investigating, 1.3% repairing, 0.1% on tooling. Manual investigation costs $5.67 per failure; auto-rerun costs $0.02 (Leinen et al., ICST 2024). That's $2,250/month per developer spent repairing flaky tests. For every week of computing time spent on testing, up to one day is used for re-running flaky tests (ICSE 2024). Rerun builds across 1,960 GitHub Actions projects accumulated 339 years of waiting time and consumed 31.6 years of computational time (Ge & Zhang, 2025).
51% of developers deal with flaky tests weekly; 66% rate it a moderate or serious problem (Gruber & Fraser, ICST 2022). 73% say they stop trusting test results once flakiness appears — they start disregarding failures, potentially ignoring actual bugs (Eck et al., FSE 2019). Each flaky failure triggers a context switch — 23 minutes of productivity lost per interruption. Google found 14% of their large tests are flaky across 4.2 million tests. Uber had 1,000+ flaky tests in a single monorepo, with ~63% of PRs needing at least one rerun (Trunk, 2024).
Not everything you call "flaky" is actually flaky. Some of those tests are real bugs. They fail every single time with the same error. You just don't notice because you've trained yourself to hit rerun without looking.
I wanted to know how many "flaky" tests are actually deterministic failures if you read the logs across 50+ runs. And whether an AI agent could do that reading for you.
What I Built
ai-flake-sleuth is a LangGraph agent that does three things:
Fetches GitHub Actions run history from any public repo (500+ runs at a time)
Parses CI logs with 15 regex parsers covering 12 test frameworks across 5 languages
Classifies each failure as REAL_BUG (deterministic, same error every time), FLAKY (intermittent, varying errors), or INFRA (timeout, OOM, network)
It runs in two phases. Download once (network required). Analyze offline (no network, no API calls unless you use a cloud LLM). The analysis produces a CI health report in three formats — CLI table, JSON, and markdown.
Repo: github.com/deghosal-2026/ai-flake-sleuth · Install: pip install ai-flake-sleuth · MIT
# Download CI data
ai-flake-sleuth download --repo fastapi/fastapi --runs 500 --data-dir ./data/ --all-runs
# Analyze with a local LLM (free)
ai-flake-sleuth analyze --repo fastapi/fastapi --data-dir ./data/ \
--llm omlx --llm-model Qwen3.5-9B-MLX-4bit \
--llm-endpoint http://127.0.0.1:8000 \
--force-llm --no-thinking --format all
# Or with a cloud LLM (~$0.0007/call)
ai-flake-sleuth analyze --repo fastapi/fastapi --data-dir ./data/ \
--llm opencode --llm-model gpt-5-nano \
--force-llm --no-thinking --format all
How it compares to what exists
| Tool | What It Does | What's Missing |
|---|---|---|
| ai-flake-sleuth | Fetches CI runs, parses 12 frameworks, classifies with LLM, correlates across runs | No auto-quarantine (by design — human decides) |
| Trunk / Flakybot | Detects flaky tests in CI | No LLM classification. No cross-run correlation. No REAL_BUG vs FLAKY distinction |
| GitHub Actions rerun | Reruns failed jobs | No diagnosis. Just retries. The problem persists |
| Manual log reading | Engineer reads 50+ run logs | Works. Nobody has time. That's the whole point |
ai-flake-sleuth owns the classification + correlation column. It doesn't just detect flakiness — it tells you whether a failure is a real bug, a flaky test, or infrastructure noise. And it does it across 50+ runs automatically.
The Field Study
I ran the agent against 21 open-source repositories. Not 5 — I started with 5 (the plan), but discovered that most repos' CI failures aren't test failures at all. They're lint failures, build failures, CodeQL analysis failures, Dependabot updates. The test jobs passed. So I kept adding repos until I had meaningful data.
What I downloaded
| Metric | Value |
|---|---|
| Repos | 21 |
| Runs fetched | ~4,500 |
| Log ZIPs downloaded | ~3,800 |
| Disk space | ~4.5 GB |
| GitHub API calls | ~5,000 (hit the rate limit once) |
The 12 frameworks I had to support
The original design only supported pytest and unittest. That lasted about 20 minutes. Real CI logs use Jest, Vitest, Turbopack, Go test, RSpec, Minitest, Mocha, PHPUnit, JUnit, Cypress. Each has a different output format. Some use PASS/FAIL keywords. Some use checkmarks. Some use dots. Some prefix every line with a GitHub Actions timestamp.
I built 13 new parsers during the study. 15 total, including pytest's two modes and a generic JS fallback.
| Framework | Language | Parser format |
|---|---|---|
| pytest | Python | test_name FAILED |
| unittest | Python | test_name (module) ... FAIL |
| Jest | JavaScript | PASS/FAIL path/to/test.test.ts |
| Vitest | JavaScript | ✓ unit path/to/spec.ts (N tests) |
| Turbopack | JavaScript | FAIL SuiteName path/to/test.test.ts (Ns) |
| Go test | Go | --- PASS: TestName (0.00s) |
| RSpec | Ruby | N examples, M failures |
| Minitest | Ruby | N runs, M assertions, K failures |
| Mocha | JavaScript | ✓ test name / ✗ test name |
| PHPUnit | PHP | PASS Tests\Path\TestName |
| JUnit | Java | testMethod(TestClass) <<< FAILURE! |
| Cypress | JavaScript | ✓ TestName (Nms) |
The Unexpected Finding: 56 Bugs Disguised as Flaky Tests
I ran the analysis with two models:
OMLX — Qwen3.5-9B-MLX-4bit, a 9B parameter model running locally on Apple Silicon. Free.
GPT-5 Nano — a cloud model via OpenCode Zen. ~$0.0007 per call.
On 4 repos (pytest, langchain, django-rest-framework, jestjs), both models agreed: everything was FLAKY. No disagreement. Clean.
On 3 repos (fastapi, vercel/next.js, rubocop), they disagreed. Hard.
| Repo | OMLX said | GPT-5 Nano said |
|---|---|---|
| fastapi/fastapi | 18 FLAKY, 0 REAL_BUG | 8 FLAKY, 13 REAL_BUG |
| vercel/next.js | 71 FLAKY, 0 REAL_BUG | 185 FLAKY, 35 REAL_BUG |
| rubocop/rubocop | 88 FLAKY, 0 REAL_BUG | 80 FLAKY, 8 REAL_BUG |
GPT-5 Nano found 56 tests that fail deterministically — same error, every run — that the local model classified as flaky. The local model found 3 real bugs of its own (2 in vue, 1 in react) that GPT missed due to a degraded run on vue.
Was GPT-5 Nano right?
I manually validated one of the 56 disputed tests. The test was tests/test_tutorial/test_testing/test_tutorial003.py::test_main from fastapi. Here's the raw log:
FAILED tests/test_tutorial/test_testing/test_tutorial003.py::test_main
- Failed: DID NOT WARN. No warnings of type (DeprecationWarning,) were emitted.
Same error. All 14 runs. Identical. That's not flaky. That's a real bug — the test expects a deprecation warning that the code isn't emitting. GPT-5 Nano was correct. The local model said INFRA because the error signature hash was empty (a data pipeline gap, not a classification error).
The pattern across all 56: tests that fail 14/14 times with the same error, but the error message is empty or generic. The local model sees "empty error" and thinks infra/flaky. The cloud model sees "14/14 deterministic failure" and says real bug. The cloud model is right.
The Bug That Was Producing Fake Verdicts
First time I ran the agent with a Qwen3 reasoning model, every classification came back as FLAKY. Every single one. I thought the model was just conservative. It wasn't.
What was actually happening: Qwen3 with thinking enabled spends its entire token budget reasoning before emitting the JSON answer. I had max_tokens hardcoded at 512. The model used all 512 tokens thinking — "Okay, let's analyze this. The test failed 14 times. The error signature is empty. Wait, let me reconsider..." — and never produced the JSON. The response was truncated. JSON parsing failed. The fallback returned FLAKY.
And the classified_by prefix was llm: — the same prefix used for real verdicts. There was no way to distinguish a real model verdict from a silent fallback. The tool was lying to me, and I didn't notice because the lies looked like real answers.
The fix took 4 changes:
Configurable
max_tokens(default 4096, was hardcoded 512)finish_reasondetection — if the response was truncated (finish_reason: length), tag itllm-truncated:instead ofllm:4 distinct prefixes —
llm:(real verdict),llm-truncated:(cut off),llm-parse-error:(bad JSON),llm-fallback:(call failed)--no-thinkingflag — disables Qwen3's reasoning mode entirely. The model answers directly. 79 completion tokens instead of 4,096. 16 seconds instead of 214 seconds. 13× faster, same or better accuracy.
After the fix, the degraded call count appeared in the report summary. 74 out of 88 calls on rubocop had been fallbacks from the local endpoint being overloaded. I had no idea until the reporting surfaced it.
What Most CI Failures Actually Are
Here's something I didn't expect. 8 of 21 repos had zero test failures in their CI logs. Not because their tests are perfect — because their CI "failures" are in other jobs.
| Repo | Failures | What actually failed |
|---|---|---|
| gin-gonic/gin | 3 | Lint jobs |
| golang/go | 6 | Git submodule, credentials cleanup |
| expressjs/express | 3 | CodeQL analysis |
| react-hook-form | 11 | Build, action, Dependabot |
| microsoft/playwright | 36 | AI analysis summaries |
| reduxjs/redux-toolkit | 7 | "Check for changes" jobs |
| spring-projects/spring-boot | 14 | Build (BUILD SUCCESSFUL, failures elsewhere) |
| django-import-export | 53 | Docker, Postgres, MySQL setup |
GitHub Actions runs multiple jobs per workflow. A run can "fail" because a lint job failed while the test job passed. The downloader captures logs for the whole run, but the test output is in a job that succeeded — and we only analyze failed runs.
This is a data collection challenge, not a parser bug. The parsers work. The data just doesn't contain test failures because the test jobs passed.
The tool handles this gracefully — clean report, zero tests classified, no crash. But it means you need to download enough runs and the right workflows to find actual test failures.
The Cost
The entire field study — 21 repos, 609 LLM calls across both models, 12 frameworks — cost $0.22 in cloud LLM calls.
| Scale | Calls | Cost |
|---|---|---|
| Single repo | 20 | $0.01 |
| This study | 303 | $0.22 |
| 50+ repos | 2,000 | $1.44 |
| Enterprise CI monitoring | 20,000 | $14.40 |
The local model is free. The cloud model is $0.0007 per call. For context: the cheapest option (DeepSeek V4 Flash) is $0.0001 per call, but it returned 400 errors on 7 of 8 repos through the OpenCode Zen gateway. The local model had a 20% degraded rate from endpoint overload. The cloud model had a 1.6% degraded rate.
What I'd Do Differently
Filter by job type at download time. Don't fetch lint/build/CodeQL/Dependabot logs. Only fetch jobs whose names match test patterns. Would have saved downloading 2,000+ irrelevant log files.
Pass per-test stats, not all-test stats. Two repos (django, vue) produced prompts exceeding any model's context window because the cross-run context included all 14,000 test stats instead of just the one being classified. Django's prompt was 9.8 million characters. That's not a model limitation — that's a code bug.
Run models sequentially, not concurrently. The local MLX endpoint is single-threaded. Running rubocop concurrently with other repos caused 74 out of 88 calls to fail with connection pool exhaustion. Cloud APIs handle concurrency naturally.
Test parsers against real logs before running full analysis. I built several parsers from documentation, then discovered the actual CI log format was different. GitHub Actions prefixes every line with a timestamp. Jest uses PASS not PASSED. Vercel has a suite name prefix. Testing against sample logs first would have caught these in minutes instead of hours.
The Honest Limitations
No manual ground truth validation for all 56 REAL_BUGs. I validated 1 of 56 by reading the raw log. The pattern (14/14 identical failures) strongly suggests the rest are also real bugs, but I haven't checked each one. A proper accuracy study would sample 20+, read the logs, and compare against human judgment.
The local model is biased toward FLAKY. Qwen3.5-9B is a 9B parameter model, 4-bit quantized. It's not surprising that it misses nuances a larger cloud model catches. But it's free, local, and private. The right approach is: run local first, then run cloud on the disagreements.
8 repos produced zero results. Not because the tool failed — because the CI failures weren't test failures. This is a data collection limitation. The tool correctly reports "clean CI" instead of crashing, but it means you need to pick repos where test jobs actually fail.
Django is blocked. The cross_run_context passes all 14,925 test stats as a single dict. The prompt is 9.8 million characters. No model can handle that. The fix is straightforward (per-test stats) but not yet implemented.
Vue GPT-5 Nano run was degraded. The Vitest parser produces a massive cross-run context (1.3M characters). Prompt truncation at 50K was added as a workaround, but the model still returns incomplete output. Proper context summarization is needed.
Show Me the Numbers
| Metric | Value |
|---|---|
| Repos analyzed | 21 |
| Frameworks covered | 12 |
| Parsers built | 15 (13 during the study) |
| Tests classified | ~1,151 (excluding django, which was blocked) |
| LLM calls (OMLX) | 306 |
| LLM calls (GPT-5 Nano) | 303 |
| Degraded (OMLX) | 76 (20%) |
| Degraded (GPT-5 Nano) | 5 (1.6%) |
| REAL_BUGs found by GPT | 56 |
| REAL_BUGs found by OMLX | 3 |
| Total cloud cost | $0.22 |
| Bugs found in the tool | 11 (7 fixed, 4 open) |
| Time end-to-end | ~8 hours |
| Test coverage | 81.95% (280 tests) |
Why This Matters
The 56 REAL_BUGs are the headline number. The deeper finding: the model you choose to classify CI failures changes what you find. A free local model said everything was flaky. A $0.22 cloud model found 56 real bugs. Same data, same prompts, same parser. Different model, different truth.
If you're rerunning flaky tests without diagnosing them, some of those "flaky" tests are real bugs. You're shipping regressions because the CI signal is noise. The fix isn't more retries. It's reading the logs.
FAQ
What is a flaky test?
A test that fails intermittently — passes sometimes, fails other times, with no code change. Flaky tests destroy CI trust because engineers stop believing test results. The fix isn't more retries. It's diagnosis.
How does ai-flake-sleuth classify failures?
Three categories: REAL_BUG (deterministic, same error every run), FLAKY (intermittent, varying errors), INFRA (timeout, OOM, network). Rules first (infra pattern matching, error signature analysis, cross-run correlation), LLM only for ambiguous cases.
Does it work with my test framework?
15 parsers covering 12 frameworks: pytest, unittest, Jest, Vitest, Turbopack, Go test, RSpec, Minitest, Mocha, PHPUnit, JUnit, Cypress, plus a generic JS fallback. If your framework isn't listed, open an issue. Adding a parser takes about 50 lines of regex.
How much does it cost?
Local model (OMLX, Qwen3.5-9B) is free. Cloud model (GPT-5 Nano) is ~$0.0007 per call. The entire field study (21 repos, 303 cloud calls) cost $0.22. You can also run rules-only with --no-llm for zero cost.
What's the difference between this and just rerunning flaky tests?
Rerunning hides the problem. This diagnoses it. A rerun tells you "it passed this time." The agent tells you "this test failed 14 out of 14 runs with the same error. It's not flaky. It's a real bug."
pip install ai-flake-sleuth
Repo: github.com/deghosal-2026/ai-flake-sleuth — star it if CI flakiness is eating your team's trust. Open an issue, drop a comment, or contribute a parser for a framework I missed.
Your CI pipeline doesn't have a flaky test problem. It has a trust problem. And you can't fix trust with more retries.
#ai #software-development #devops #python #flaky-tests #langgraph
About the author
- Engineering leader with 25 years building CI/CD platforms, developer experience tooling, and cloud infrastructure at Warner Bros. Discovery, Microsoft, and Nordstrom. Currently building production-grade AI agent systems — circuit breakers, model routing, cost boundaries, and reliability patterns for LLM agent loops. Author of ai-loopguard, an open-source circuit breaker for agent loops.
Comments
Join the discussionNo comments yet. Be the first to comment.
Pragmatic AI Tools
Every article ships a real open-source tool. loopguard, flake-sleuth, incident-commander, tierforge. The name matches your publication. Each post: here's the problem, here's the tool I built, here's what happened when I ran it