Debugging With AI: From Symptom to Verified Root Cause

Debugging With AI: From Symptom to Verified Root Cause

Feed the agent verbatim evidence, treat its explanations as hypotheses to falsify, and watch for the symptom patch that silences an error without touching the cause.

Agents can accelerate diagnosis when you feed them verbatim evidence rather than paraphrase, treat their confident explanations as hypotheses with a cheap test attached rather than verdicts, and let them run the instrument-and-observe loop while you watch for thrashing. One failure to guard against is the symptom patch — a null check or swallowed exception that makes the error disappear while the cause lives on. The acceptance question for any fix is whether its explanation accounts for why the bug appeared when it did, and the fix closes with a test built from the reproduction, so the same bug coming back along that path fails the test instead of passing unnoticed under a different stack trace.

What the agent needs to diagnose

Diagnosis turns on detail, and the first job is to hand the agent the detail intact. Verbatim evidence beats paraphrase: the exact stack trace, the exact log lines, the failing input — not your summary of them. Summaries strip the specifics diagnosis depends on. "It throws a null error somewhere in checkout" has discarded the frame, the line, and the value that would have pointed straight at the cause; the raw trace still carries them.

A minimal reproduction is worth more than a long description. If a repro exists — the smallest input and steps that reliably trigger the failure — it leads the context, because it converts the problem from a story the agent has to imagine into a fact it can reason against. Everything else is secondary to a case that fails on demand.

Include what already did not work. The theories you have ruled out, the fixes you tried that changed nothing — stating them up front saves the agent from confidently re-proposing your last three dead ends, which it may do if it does not know you have been there. Ruling-out is evidence too, and it is easy to leave out of the context.

Hypotheses, not verdicts

An agent can produce a confident causal narrative whether or not it is right. A fluent explanation is not evidence that the explanation is correct. In a 2023 study by Turpin et al., language models (GPT-3.5 and Claude 1.0) that had been biased toward incorrect answers by features added to their inputs frequently generated chain-of-thought explanations rationalizing those answers, and the authors write that such explanations can be plausible yet misleading. An account of why the bug happens can read as smoothly when it is wrong as when it is right. Taking that narrative as a verdict is how a debugging session goes fast in the wrong direction.

The working posture is to treat every proposed cause as a hypothesis with a cheap test attached. For each explanation the agent offers, the immediate question is: what is the smallest thing that would confirm or kill this — a log line, an assertion, a narrowed repro? A hypothesis you can falsify in thirty seconds is worth more than one you find persuasive, and the persuasiveness is not the signal.

This turns the agent's fluency into something useful instead of dangerous. Asking for several competing hypotheses, ranked by how cheaply each can be falsified, converts a confident single story into a search strategy: you run the cheapest discriminating test first and let the evidence, not the phrasing, narrow the field. The agent can generate the candidate list quickly; deciding among them stays with the evidence you gather.

Letting the agent run the loop

An agent that can execute — add instrumentation, run the repro, read the output — closes the loop a human otherwise walks by hand, and iterating on the same method faster is where a lot of the value is. Instrument, run, observe, narrow, repeat: the method is unchanged, the cycle time drops.

The value condition is that each iteration must produce evidence, not just another edit. The warning sign is thrashing — repeated speculative fixes with no new information between them, the agent changing code and re-running in the hope that something goes green rather than to learn something. A loop that adds a log line, reads it, and narrows is working; a loop that swaps implementations without observing is guessing at speed, and speed makes it worse, not better. Watching for that distinction is the human's job in the loop.

Instrumentation the agent adds is temporary scaffolding. The log lines, the extra assertions, the debug prints that helped locate the cause come out in the final diff unless a specific one is worth keeping deliberately. A fix that ships with a scatter of leftover debug output has not finished; the diagnosis code and the fix are different things, and only the fix belongs in the change.

The symptom-patch trap

One failure to guard against in assisted debugging is the fix that makes the error message disappear without touching the cause. A null check swallows the null instead of explaining where it came from; a try/catch catches and quietly moves on; a type is widened so the invalid value now fits. The symptom is gone, the test is green, and the cause is exactly where it was, waiting to resurface somewhere the patch does not cover.

python
# Symptom patch: the error stops, the cause is untouched
def total(order):
    if order.customer is None:      # why is it ever None here? unasked
        return 0                    # the null is silenced, not explained
    return sum(i.price for i in order.items)

The acceptance test for any proposed fix is causal, not cosmetic: does the explanation account for why the bug appeared when it did, and does the fix fail without that explanation? If a change makes the error go away but nobody can say why the bug was happening in the first place, it is a symptom patch — the null above should send you to whatever produced an order with no customer, because that is the defect; the guard is at best a downstream courtesy. A fix you cannot connect to a why is a fix you cannot trust.

Regression protection lands with the fix, not after it. The reproduction that exposed the bug becomes a test, so if the same failure comes back along that path, even wearing a different stack trace, the test fails instead of letting it pass unnoticed. This is also the honest bound on the whole practice: agents can speed up hypothesis generation and run the loop, but finding the root cause is not something to hand over — the verification, the causal acceptance test, and the regression that pins the fix stay with the engineer. Any speed-up is worth measuring rather than assuming; the judgment is not delegated.

Project Inquiry