AI keeps changing code without fixing the bug: how do you establish a minimal failing path?
When repeated AI changes do not resolve a bug, fix a reproducible minimal input, startup command and observable failure before editing a specific path. Without reproduction, changing implementations repeatedly can add unrelated behavior.
Start troubleshooting here
When repeated AI changes do not resolve a bug, fix a reproducible minimal input, startup command and observable failure before editing a specific path. Without reproduction, changing implementations repeatedly can add unrelated behavior. Verify the original failing sample and neighboring valid cases and inspect the diff; startup success or a plausible explanation does not establish repair.
Reduce the user action to a repeatable failing input
This applies when one edit temporarily removes an error but another input fails or an agent experiments across unrelated files. Preserve working-tree state and separate existing user changes from current attempts. Record the stack trace, request path and actual input, retaining the structure that triggers the same failure after removing private information.
Confirm the failure location and the version actually running
Follow the actual execution chain to confirm entry point, dependency versions and failure location, including stale builds or programs running from another directory. Reproduce with a small sample and state expected versus actual behavior. For external-service failures, preserve a safe response sample or representative substitute; a stub that always succeeds does not locate the original problem.
Fix the identified path and inspect the diff
Make the smallest change supported by the identified cause and review changed files and effects after each attempt. Avoid mixing unrelated refactoring and dependency upgrades. Add an assertion for the original error where useful, with diagnostic input in its failure message. Use reversible experiments for uncertain causes and retain evidence rather than accumulating ineffective experiments in the final patch.
Show the original sample failing before repair and passing afterward
Confirm the reproduction fails before the fix and meets expectations afterward, then test adjacent boundaries and established behavior. Interface and API bugs need their actual path checked rather than just an isolated function. Report executed commands and outcomes. If an external environment is unavailable, describe the remaining scope instead of claiming all tests passed.
This article did not run your project or claim a successful repair; it describes evidence-based debugging. Minimization must preserve the conditions that actually cause the bug, and concurrency failures may require timing traces. Passing tests cannot prove every input correct, but reproducible evidence supports a fix. Do not delete failing assertions to obtain green results.
Checked sources
These sources support the concepts and methods described here. Examples and test scope are labeled separately; check the version of the tools you use.