
The first CI attempt fails. The rerun passes. An AI assistant reads the latest result and calls it fixed. That is how a real failure becomes an unexplained green check.
A retry can keep work moving, but it is also an experiment. A pass tells you that the failure did not appear on that attempt. It does not tell you whether the problem lived in the application, the test, or the runner. Give AI the evidence from both runs and ask what changed before asking for a patch.
Keep the failed attempt
Start with the first meaningful failure, not the last line of the log. An assertion failure, a service that never started, and a runner that lost its connection are three different problems. Save the failing step, test name, run and attempt numbers, commit, job matrix, and the relevant error and stack trace. Record the runner image, tool versions, shard, worker count, and any random seed or order your test runner reported. Preserve only the diagnostic artifacts you need, and remove secrets and personal data before sharing them with an AI service.
GitHub Actions reuses the triggering SHA and ref on a rerun, but some unchanged jobs can keep outputs from the earlier attempt when you rerun only part of a workflow. A second job may still use a different runner or encounter different cache, service, or network conditions. If you need the complete sequence, retrieve logs from the relevant attempts, not just the latest archive.
Choose one comparison that separates two explanations
Suppose a fictional library app has a test that exports a catalog to a temporary directory. It sometimes fails with an unexpected title when CI runs multiple workers. The wrong row could come from an earlier test that left state behind, or from another worker writing to the same path at the same time. These are hypotheses, not diagnoses.
| Comparison | What it helps distinguish |
|---|---|
| Test alone vs. after one suspected predecessor, each in a fresh serial run | If only the second arrangement fails, inspect what the predecessor leaves behind. |
| Same suite and seed with one worker vs. multiple workers | Failures concentrated in the parallel run point toward shared resources or timing, not necessarily one specific race. |
| Same desired parallel run with shared vs. unique export directories | If only the shared directory produces the wrong title, file ownership is a more useful lead than a longer timeout. |
Keep the commit, dependencies, and input data fixed for each pair. Record which cases actually ran on each worker rather than assuming a fixed seed controls concurrent scheduling. pytest’s guidance on flaky tests describes how test ordering, missing cleanup, and parallelism can expose hidden dependencies. Running everything serially may help identify the trigger; making serial execution permanent could leave the underlying bug untouched.
Tell the agent what a retry can change
Retries do not always repeat the exact failure conditions. Playwright Test starts a fresh worker process and browser after a test fails, and it marks a test that later passes as flaky. That fresh worker can clear process-local state, while a file or shared database may persist. For a diagnostic run, preserve evidence from the original failure where practical. For example, Playwright’s trace options distinguish keeping a trace of the first failed attempt from recording only the first retry.
Ask the agent to return three things: what it observed, what is still uncertain, and the next controlled comparison. If the evidence points to a shared output path, a narrow fix might allocate a directory per test and clean it up afterward. If the app itself uses one shared path for simultaneous exports, changing the test setup alone could conceal a product bug. Check which component owns the resource before editing.
Verify the change under the conditions that exposed it
Compare failure counts before and after the patch in repeated runs under the same suspect conditions. A useful report might say, “Failed 6 of 30 parallel runs before the patch and 0 of 30 afterward; no additional retries enabled.” Those are illustrative numbers, not a guarantee of stability. Also rerun the relevant suite under its usual CI configuration to check that the fix did not change unrelated behavior.
If you temporarily quarantine a disruptive test, give it an owner, a reason, and an explicit review date. Keep its status visible. The useful outcome is not one green badge. It is knowing what conditions produced the failure, what the change addressed, and which uncertainty remains.