πŸ€– HarDojo
Log in Sign up

Debugging with Agents

Use the agent as a pair debugger β€” and feed it the right evidence.

Agents are excellent debuggers when you give them evidence instead of vibes.

The evidence-first prompt

Include the actual failure, not your guess:

"When I call POST /checkout with an empty cart, I get: TypeError: Cannot read properties of undefined (reading 'total') Stack trace: ... (paste it) Relevant files: src/checkout.ts, src/cart.ts Find the root cause and fix it. Add a test for the empty-cart case."

The stack trace, the input, and the files are the prompt.

Debugging workflows

Rubber-duck with the agent

"Explain what this function does, line by line."

Often the explanation reveals the wrong assumption.

The bisect approach

"This worked in commit abc123 but fails on main. Here's the diff. Which change most likely caused it?"

Hypothesis testing

"I think the bug is that cart.total is undefined before the first item is added. Verify or refute, then fix."

Asking the agent to verify or refute keeps it from just agreeing with you.

Common mistakes

  • No error message. "It doesn't work" is not a bug report.
  • Guessing the cause. You bias the agent toward your (possibly wrong) theory.
  • Dumping 50 files. Context clutter hides the signal.
  • Letting it silently guess. Demand a root-cause explanation before the fix.

The golden loop

reproduce β†’ gather evidence β†’ form hypothesis β†’ fix β†’ test β†’ verify

Use the agent at every step, but you drive. It's a pair programmer with infinite patience, not an oracle.

Paste the error, not your conclusion. The error message is ground truth; your conclusion is a hypothesis.