Debugging with Coding Agents: Evidence Grading and Minimal Fixes
Coding agents can already read code, search logs, run checks, and draft patches, yet "being able to call tools" is not the same as "finishing the repair." This article describes the most common failure mode—task drift—and presents a practical framework for keeping agents on target: a testable fault statement, three levels of evidence, disciplined handling of tool failures, goal replay after context compression, minimal reversible fixes, scoped permission requests, and trajectory-based evaluation. Readers will learn how to turn these principles into an execution protocol and evaluation harness that measures process discipline rather than fluent-sounding explanations.
Debugging with Coding Agents: Evidence Grading and Minimal Fixes
Coding agents can already read code, search logs, run checks, and draft patches, but “being able to call tools” is not the same as “finishing the repair.” In real-world troubleshooting, the most common failure is not a complete inability to answer. Instead, the trajectory looks diligent: terminology gets repeatedly unpacked, probing expands again and again, weak signals are cautiously refused promotion, and in the end nothing resembling an executable, reversible, verifiable minimal fix is produced. When the user interrupts to ask about progress, the system often promises to “get back to the root cause,” then drifts back into permission expansion or integrations unrelated to the goal.
This behavior can be summarized as task drift. The original goal is to restore some user-perceivable function—say, a failing request, inconsistent data, or a resource leak. The agent instead treats intermediate observations as new primary tasks, bouncing between localization, environment, permissions, and external systems. To judge whether a coding agent is reliable, you should not look only at whether a single answer is fluent; you should look at whether it can hold onto the goal across a long trajectory, use evidence in a graded way, and stop exploring once sufficient information appears.
Fix the Fault Statement First
At the start of troubleshooting, write down a testable fault statement: who was doing what, at which entry point, what they expected, what was actually observed, and what the scope and time window of the impact are. The statement must distinguish symptoms from causes. “The API returns an error” is a symptom; “a particular deployment changed how null values are handled” is the cause hypothesis that remains to be verified.
Terminology clarification should serve this statement, not replace it. When you encounter words like “timeout,” “leak,” or “inconsistency,” confirm whether they refer to latency, connections, memory, messages, or data—but the clarification must have boundaries: only resolve ambiguity that affects localization and repair. Do not turn every term into an independent research topic. A practical approach is to maintain three lines of working memory:
- User goal: the external phenomenon to be restored or explained.
- Current hypotheses: keep at most two or three falsifiable hypotheses.
- Next evidence: the minimal observation needed to distinguish among these hypotheses.
After each round of tool calls, check against these three lines. If the next piece of evidence cannot raise the likelihood of any hypothesis, or cannot rule one out, that call should not happen.
Grade Evidence into Three Levels
Agents tend toward two extremes: either they jump to a conclusion from a single log line, or they declare that “nothing can be determined” about any piece of evidence. The engineering-sound approach is three levels of evidence.
Level one is observation. It describes only what the tools actually returned—for example, an error count rose during a given period, a function throws an exception for a specific input, or a configuration disagrees with its documentation. Observations carry no cause.
Level two is direction. When multiple observations point to the same area, you may narrow the search space—for example, “the problem is more likely on the write path than the read path.” Direction justifies continued investment but not changes to production logic.
Level three is conclusion. A conclusion is reached only when observations can explain the symptom, competing hypotheses are clearly weakened, and a testable fix or workaround exists. A conclusion must state its counterexample: what new evidence would overturn it.
Weak evidence must not skip levels. Elevated humidity only means “worth looking in this direction,” not “declare the pipe burst”; likewise, an increase in error logs in some module only means “this module is worth investigating,” not “rewrite the core algorithm.” But strong evidence must not be endlessly diluted either. If input, call stacks, change records, and a reproduction all line up, continuing to claim that “we still cannot be certain” is not rigor—it is an inability to stop.
Failures Must Not Be Extrapolated Outward
A tool failure is information, but the information is limited. A retrieval timeout only means that this retrieval did not complete; it does not mean the codebase contains no relevant implementation. A failed measurement only means that this measurement method was ineffective; it does not mean some new, unverified physical or environmental fault exists. The unavailability of one localization or identity service does not imply that other systems are also unavailable, much less that it is the root cause of the current task.
Each failure may only update three kinds of state: the method is temporarily unavailable; which cheaper alternative observation should be used instead; and whether a stopping condition has been reached. Deriving a new grand problem from a failure is forbidden—do not expand one anomalous reading into an investigation of the environment field, the localization system, or an external organization. New problems must independently satisfy the threshold of “having a causal chain to the original symptom”; otherwise they are recorded as a bypass and must not occupy the main trajectory.
Replay the Goal After Context Compression
Long conversations get summarized. Summaries tend to preserve the agent’s most recent threads of exploration while dropping the user’s original symptom and the hypotheses already ruled out. After compression, the model keeps working on the branch it last remembers—environment interference, permissions, external coordination—while the user is still waiting for the leak, error, or timeout to be fixed.
Before and after compression, force a replay of the same template: original symptom; confirmed facts; ruled-out hypotheses; the not-yet-run minimal experiment; and whether a fix is already possible. If a summary cannot fill in these five items, treat it as corrupted: ask the user rather than continuing along the old branch. A progress inquiry from the user is a high-priority event. The correct response is to report using the five items above and name the single piece of evidence still needed—not to generate another promise of “I will continue working on some side issue.”
Minimal Fix Before Perfect Explanation
A root-cause explanation must be able to guide a change. Stating that “some traffic left the expected path” as a conclusion, without specifying which segment, which condition, or which change, is merely a restatement of the symptom. An acceptable root cause includes at least: the trigger condition, the location of the failure, why it explains all the key symptoms, and why it is not one of the main alternative hypotheses.
The fix should default to minimal change:
- Change only the branch, configuration, or data repair directly related to the conclusion.
- Keep interfaces and data structures compatible, unless the incompatibility itself is the defect.
- Provide a rollback point and verification steps: the original request should return to the expected result, and adjacent paths must not regress.
- No opportunistic refactoring, no cleaning up unrelated alerts, no broadening dependency upgrades.
Verification should use the same input that triggers the symptom. Running only unrelated unit tests or observing that the service “has started” does not count as a completed fix. If the production environment cannot be experimented on directly, first reproduce on isolated data or replayed traffic, then apply the change.
Request Permissions Scoped to the Action
When a fix requires external systems, the agent may state which authorization it lacks, but the requested scope must equal the next action. Reading a log, restarting a class of tasks, and modifying a configuration are three different permissions. It must not request undifferentiated full access on the grounds of “needing to communicate with the integration team,” nor attempt to bypass normal validation when credentials are insufficient.
After the user provides credentials, they may only be used for the declared action, and use must stop when the action completes. Refusing to keep guessing, refusing to impersonate identities, and refusing to observe unrelated environments are all correct constraints—but constraints are not progress. Progress is: where the credentials were used, whether the call succeeded, and whether the symptom disappeared.
Use Budgets and Evaluation to Constrain Behavior
Teams can write the above principles into the agent’s execution protocol rather than relying on improvisation. The protocol includes: update the three-line working memory each round; tool calls have count and time budgets; after two consecutive rounds that fail to distinguish hypotheses, converge by asking the user; any new branch must document its causal chain to the symptom; before reaching a conclusion, list the excluded hypotheses; the patch description must include verification and rollback.
Evaluation should not look only at whether the final answer is correct—replay the entire trajectory. Four categories of test cases are useful:
- Goal retention: after an irrelevant error is injected mid-run or the context is compressed, does the agent still return to the original symptom?
- Evidence discipline: do weak signals only narrow the scope, and does closed evidence stop exploration?
- Failure boundaries: is a single tool failure contained as a method failure rather than spawning new tasks?
- Minimal fix: does the patch touch only the code related to the conclusion, and is it verified using the original symptom?
Score both outcomes and cost. A trajectory that spends a long time, makes many tool calls, and ends with a tautological conclusion should score lower than one that quickly produces a small verifiable patch. Premature modification should also be penalized: changing core logic without a reproduction is equally a failure.
A schematic trajectory check can be as simple as this:
assert goal_unchanged(trace, original_symptom)assert no_branch_without_causal_link(trace)assert evidence_level(conclusion) == "closed"assert patch_files <= hypothesis_scopeassert verification_uses(original_repro)
These assertions check process discipline and do not depend on any particular model or platform. Logs, code retrieval, task records, and permission approvals can all be implemented with generic logging services, code repositories, and identity/authorization capabilities. The key is to record “why the call was made, what it returned, and whether it changed any hypothesis” so that a human can review it.
The Right to Stop in Human–Agent Collaboration
Agents are suited to searching, comparing against changes, generating candidate patches, and running regression checks; humans are responsible for confirming business semantics, risk, and whether to proceed. Hand control back to the user when any of these signals appear: the same hypothesis has exhausted its low-cost evidence; the fix would change monetary or permission semantics; production writes are required; an external organization refuses to cooperate; or the user explicitly asks “is it fixed yet?” while no verified result exists.
When handing back, do not just apologize. State the paths already ruled out, the one feasible next step, and the risk of doing nothing. That way the human can decide to continue authorizing, narrow the scope, or switch to manual handling.
A reliable coding agent is not one that never makes a judgment, nor one that modifies the system the moment it sees a clue. It anchors on the user’s symptom throughout, makes every tool call serve the purpose of distinguishing hypotheses, contains each failure to that failed attempt, restates the goal when the context shrinks, and produces a minimal, reversible, verifiable fix when the evidence closes. Evaluating these trajectories tells you far more about whether an agent is ready for day-to-day engineering troubleshooting than watching a fluent self-explanation.
