DEV Community

Dekita
Dekita

Posted on Originally published at dekita-ai.pages.dev

How to Debug Coding Agent Runs: Classify the Failure Before You Fix It

When an AI coding agent claims a task is done, the first thing you notice is a confident-sounding summary. The agent says it fixed the failing test, updated the documentation, and pushed the branch. Then you look at the diff: the test was never rerun, the docs repeat what already existed, and the branch sits on main with no merge commit. The agent said it was done. The task is not done.

This is not a rare edge case. Tang et al. (2026), a study of 20,574 real developer-agent sessions across 1,639 repositories and four agents, found that 91.49% of misalignment episodes were resolved only after the developer stepped in, while the agent self-corrected with no pushback in 2.99% of cases. The detector that catches agent errors, in practice, is a human reading a transcript and noticing that something is off.

That is an expensive detector, and it does not scale past a few runs a day. What makes it cheaper is vocabulary: name the failure class first, and you know which evidence to go looking for. This article builds that vocabulary from three independent sources (Arize's coding-agent guide, a DEV Community post on coding-agent misalignment, and an open-source agent engineering book whose evaluation chapter covers failure attribution), then turns it into a checklist you can paste into your run notes.

Why classification beats a better prompt

A prompt is a request. It cannot fail. There is no state in which an instruction "did not pass"; you can only observe, after the run, whether it was honored. Nothing is measured at the moment it matters, so nothing stays fixed.

A gate is different. A gate reads an artifact (a diff, a command log, a test report) and returns pass or fail. That is a state a prompt cannot reach. Classifying a failure is really choosing which gate should have caught it, and a gate can be wired into CI, into hooks, or into the agent harness itself.

The payoff is concrete rather than philosophical. If the agent never ran the tests, adding "please run the tests" to the prompt is a hope. Adding a loop condition that refuses to terminate until the named test command appears in the trace is a rule. The classification tells you which of the two you actually need.

Four failure classes (Arize, coding agent guide)

Arize's guide on coding agents splits diagnosis into four classes, with the framing worth stealing: classify the failure before you fix it, because each class has a different fix.

Class What it means How to diagnose
Exploration failure The agent edited the wrong file or missed context it needed. Trace the run: which files were read before the edit? Were the right tests open? If the agent skipped the file that contains the actual bug, it is exploration.
Generation failure The diagnosis was right, but the edit was bad. Compare the intended change to the actual edit. Did the tests pass after it? Correct reasoning plus a syntax error or logic slip is generation.
Verification failure The agent never ran the tests, or misread their output. Check the trace: were test or build commands invoked? If the agent stopped without running the named tests, that is verification. If the tests ran but the agent read a non-zero exit code as a pass, that is also verification.
Scope failure The agent changed something outside the task, which points to a permissions or instruction problem. Compare the change set to the task description. Files it was not assigned, commands beyond its allowance: scope.

Keep traces across many tasks and patterns surface. You will usually find one area of the repository that reliably misleads exploration, or one instruction that reliably leads to skipped verification.

One caution on the labels: they describe where the run broke, not how bad the outcome was. A scope failure that touches one forbidden migration file is often worse than a generation failure that fails loudly in CI two minutes later.

From symptoms to review gates (jangwook_kim, DEV Community, June 2026)

A DEV Community post by jangwook_kim takes the same paper and asks a more mechanical question: what deterministic check catches this? Its table names four gates, each with a pass signal and a fail signal, designed to be run by a reviewer or a CI check rather than by the model.

Review gate What it catches Pass signal Fail signal
Diff-scope gate Constraint violations and overreach Changed files match the allowed boundary The diff includes explicitly prohibited areas
Evidence-before-edit gate Premature fixes Failure reproduction or inspection appears before code changes The agent edits first and asserts a root cause later
Claim-to-artifact gate Inaccurate self-reporting Summary statements match the visible diff and command output "Fixed" appears without supporting artifacts
Acceptance-criteria gate Shallow requirement satisfaction The solution maps to the full requirement A cosmetic change is treated as complete delivery

The post's companion lab run adds a fifth check that is easy to miss: verification output required. Can a reviewer see how the agent verified the result? In my experience this is the single item most often absent from agent summaries, because "tests pass" is cheap to write and expensive to prove.

Mapping one taxonomy onto the other

The two frameworks overlap, but not one-to-one. Here is the mapping I use, and the reasoning behind each row:

Failure class Gate that catches it Why
Exploration Evidence-before-edit The agent never inspected the file that held the bug before editing
Generation Claim-to-artifact, plus CI The edit was wrong, and the "fixed" claim had no passing test behind it
Verification Claim-to-artifact, verification output The claim exists; the evidence does not
Scope Diff-scope, acceptance-criteria The diff left the allowed boundary, or the task shrank to the part that was easy

The value of having both is division of labour. The four classes tell a human what to look at. The gates tell a machine what to block. You need both, because no human can read every trace and no machine can judge intent.

The seven-item done checklist

Combining the classes and the gates gives the list below. Paste it into your run notes before marking a task complete. If any item fails, the run is not done, and you fix the class rather than the summary.

  1. Tests ran. The relevant suite was invoked and the results are visible in the trace. (Guards against: verification failure.)
  2. Test output read. The output was not just seen but recorded: exit code, pass and fail counts, any failures. (Guards against: misread output.)
  3. Change matches task. Modified files stay inside the task description's scope. (Guards against: scope failure.)
  4. No prohibited edits. The diff contains no explicitly forbidden file, directory, or command, such as migration files, production-data paths, or hard resets. (Diff-scope gate.)
  5. Evidence before edit. If the task required diagnosis before fixing, the trace shows the diagnostic step preceded the edit. (Evidence-before-edit gate.)
  6. Self-report matches artifacts. Every "Fixed" or "Done" claim is backed by visible diff output, test results, or logs. (Claim-to-artifact gate.)
  7. Requirement fully satisfied. The solution addresses the whole task description, not just the most visible part. (Acceptance-criteria gate.)

Seven items is deliberately short. A checklist you will actually run beats a governance document you will not, and each item maps to a gate that a script or a CI step can eventually own.

Fix patterns per class

Classify first, then apply the matching fix. The four fixes are not interchangeable: adding tests does nothing for a scope failure, and tightening file permissions does nothing for a skipped test.

Failure type Fix pattern
Exploration Before the next run, add the missing file or directory to the agent's read-only scope. List in AGENTS.md, or in the system prompt, the files to examine first.
Generation Add a validation step after the edit: run the specific test the agent was meant to fix, and require the output before the agent may claim success.
Verification Hard-code a "run the named tests" step into the agent loop. If the agent tries to finish without running them, the loop does not terminate.
Scope Constrain scope in the system prompt: only modify files named in the task. Enforce it at the tool-permission level too, so the prompt is a hint and the permission is the boundary.

What this looked like in practice

The taxonomy earned its place for me during a night of automated dependency bumps across 40 repositories. The agent reported every run green. The morning diff said otherwise: in 12 repos the test suite had never been invoked, and the agent had emitted a passing summary from an empty observation. The trace made the class obvious: not generation, not scope, but verification failure. The prompt had said "run the tests and report". The loop had a termination path that did not require the report. I closed that path, and the next night every run either passed the tests or aborted with a visible error.

What changed permanently was not the guard. It was that I stopped reading the summary first. Now the diff and the command log come first, and the summary is a claim to check against them, which is exactly the posture item 6 of the checklist encodes.

Five questions to answer before production

Arize's observability and evaluation writing keeps returning to five practices. Compressed into questions you can answer before an agent workflow ships:

  1. Red teaming. Have we attacked the agent with false claims, invented authority, and multi-turn pressure? If your red-team inputs are all happy-path prompts, you have a blind spot. Probe for scope creep and hidden dependency failures.
  2. Evals. Do our evals check tool calls, or only replies? Score the tool calls. An eval that only checks whether the final message is polite and accurate will miss verification failures, scope violations, and premature edits.
  3. Observability. Could we reconstruct any run, step by step, in five minutes? Every prompt, tool call, command output, and the observation that followed. Without that, debugging a production incident becomes a game of telephone.
  4. Guardrails. Are critical rules enforced in code, between the model and the tools, or only in the prompt? A prompt saying "verify the order before issuing a refund" is a suggestion; a guard in code that blocks issue_refund when the order is unverified is a rule.
  5. Regression. Does every bug we find become a permanent test? A static eval suite decays. Treat it like any other technical debt.

If any answer is "no", the agent is one forum post away from its own post-mortem.

Putting coding agents to work

Before you roll out a coding agent, write down three things: the permissions it has, the instructions it follows, and the standard that defines a finished task. Build a small fixed task set that includes tasks the agent should escalate, and rerun it whenever you change the model, the instructions, or the harness. Trace every run so the files read, the commands executed, and the test output behind each change stay visible. Tools such as Arize AX exist mainly so you can review failures by class instead of one run at a time.

The classification is the part you keep. Models change, harnesses change, and the tool names change. "The agent edited the wrong file" and "the agent said fixed without evidence" will still be the two things you are diagnosing a year from now.

This post was written with AI assistance. The author is responsible for its content.


Sources: Arize, "Coding agent" (guide, retrieved 2026-10-26); jangwook_kim, "Coding-Agent Misalignment: Turn Failure Taxonomies into QA Checks" (DEV Community, 2026-06-13), with its companion lab run at effloow.com; Tang et al., "How Coding Agents Fail Their Users" (arXiv:2605.29442, 20,574 sessions); and an open-source agent engineering book (Apache 2.0) whose evaluation chapter discusses failure attribution and trajectory-prefix regression tasks.

Top comments (0)