Skip to content
New — orchestrate a team of Mel agents from your terminal. Learn more about orchestrating Mel agents
Mel
← All articles

Mel – the agentic terminal
The agentic team for coding.

How to debug an error with an AI coding agent

November 22, 2026 · 5 min read

Share
Guides: Debug with an agent
In short
  • Give the agent the exact error, where it happens, and the command that proves it is fixed.
  • In Mel, Ctrl+Up attaches the last failed command and its output to the agent.
  • The agent reproduces the error, changes the code and runs the check again before it reports back.
  • Every edit shows its exact diff on an approval card before it is written.

To debug an error with an AI coding agent, give it three things: the exact error, where it happens, and the command that proves it is fixed. In Mel – the agentic terminal (openmel.dev), the fastest way is to run the failing command in the terminal, press Ctrl+↑ (⌃↑ on a Mac) to attach that command and its output, and say what "fixed" means, for example "make npm test pass". Mel's agent reads the code, reproduces the error, changes what it needs, and runs the check again before it reports back. Every edit and command that changes something waits for your approval unless your settings allow it.

This guide covers why agents get debugging wrong, a five-step method that works, how to do each step in Mel, and the mistakes that send an agent in circles.

Why do AI agents get debugging wrong?

An agent that guesses is worse than no agent. The three usual causes:

  1. No real error. "The login is broken" gives the agent nothing to reproduce. It guesses a cause and "fixes" code that was never wrong.
  2. No finish line. Without a command that proves the fix, the agent stops at the first change that looks plausible and says "done".
  3. Too much context. A 2,000-line log hides the three lines that matter, and the agent chases the wrong warning.

Each of these is fixed by what you put in the message, not by a better model.

A five-step method for debugging with an agent

StepWhat you doWhy it matters
1. ReproduceRun the failing command yourselfThe agent sees the real error, not your summary of it
2. AttachGive the agent that one command and its outputExact text, nothing extra
3. Set the finish lineName the command that must passThe agent knows when to stop
4. Set limitsSay what must not changeIt fixes the bug, not the design
5. ReviewRead the diff, then run the check yourself"Done" is a claim until you see it

How to do each step in Mel

1. Reproduce the error in the terminal

Run the command that fails, such as npm test, pytest -x or cargo build. A failed command gets a red ✗ badge and its whole block turns red, so you can find it again in a long session. See blocks.

2. Attach the failing block

Right after a failed command, the hint row under the prompt offers to attach it. You have three ways:

  • Press Ctrl+↑ (⌃↑ on a Mac) at the prompt to attach the last command and its output.
  • Right-click the block and choose Attach as agent context.
  • Click the paper-clip icon in the block's header.

Attach the one block that fails, not a whole log. Everything you attach counts toward the model's context.

3. Say what "fixed" means

Press Ctrl+Enter (⌘↵ on a Mac) to hand the message to the agent, and write the task like a ticket:

The test above fails since this morning's merge.
Find the cause and fix it.
Done means `npm test` passes, with no test skipped or deleted.
Don't change the public API of src/auth.

If your project has an AGENTS.md that names its test command, Mel's agent reads it and uses that command to check its work. Starting a dev server or reading a file back does not count as a check. See how to write a good task.

4. Approve what it does

Mel's agent reads files and searches freely, because reading changes nothing. An edit shows an approval card with the exact diff it will write, and a command that changes something shows the exact command. You allow it once, allow that kind of step for the rest of the conversation, or deny it, and the agent changes course. See tools and approvals.

Some steps always wait for you, whatever your settings: a command Mel recognises as impossible to undo (such as git push --force, git reset --hard or sudo), reading a file that holds credentials, writing outside the project, and any connector call.

5. Review the fix

Every edit leaves a diff card in the conversation. Press Ctrl+Shift+= (⌘⇧= on a Mac) to open the code review panel and read the whole change. Hover a line and click 💬 to leave a comment, then send your comments back to the agent to fix. When it is right, Approve and Commit.

What if the agent goes in circles?

Mel stops some loops by itself. Running the same command a third time with nothing changed in between is stopped, and a task that stops making progress ends with a report of what was done and what is left. When that happens:

  • Narrow the task. "Find which commit broke test_login" before "fix it".
  • Add one fact. The last version that worked, or the input that fails.
  • Try another model. Mel works with Claude, GPT, Gemini, DeepSeek, Qwen and more, so a second opinion is one click in the model menu. See which AI models you can use in Mel.
  • Stop it. The stop button ends the turn at once. Background jobs keep running, each with its own Stop.

Mistakes that waste a debugging session

  • Describing the error instead of attaching it. The exact text matters.
  • "Fix the tests" as the whole task. An agent may make tests pass by deleting them. Say "no test skipped or deleted".
  • Pasting a huge log. Attach the one failing block.
  • Approving without reading. The card shows the exact diff. Read it.
  • Trusting "done". Run the check yourself once at the end.

Frequently asked questions

How do I give an AI agent the error from my terminal? In Mel, press Ctrl+↑ (⌃↑ on a Mac) at the prompt to attach the last command and its output, or right-click the block and choose Attach as agent context.

Can the agent run the tests itself? Yes. Mel's agent runs commands in your project, reads the output, and runs the check again after it changes something. A command that changes something waits for your approval unless your settings allow it.

Will the agent delete my files while debugging? Not without asking. Edits and commands that change something stop at an approval card unless you allow them, and steps Mel recognises as impossible to undo always wait for you.

What if the fix is wrong? Undo it in the code review panel: Undo takes back one change, and ↩ Discard reverts one file. See how to undo what an AI coding agent changed.

Does this work with Claude Code or Codex? Yes. You can run claude or codex in a Mel tab and give them the same kind of task. They run on your own Anthropic or OpenAI account. See running Claude Code and Codex together.

Is Mel free for debugging? The terminal is free, and Mel's agent is free with your own API key. Paid plans start at $20 a month. See pricing.

Try it

Download Mel, run the command that has been failing all week, press Ctrl+↑ and write one line: what done looks like. For more on writing tasks, read how to write a task an agent can finish.

Mel – the agentic terminal · openmel.dev. The agentic team for coding.

Found this useful? Share it with your team.
Share
Lalla Asmaa Alaoui
Written by
Lalla Asmaa Alaoui
Founder & CEO of Mel

Lalla is a hands-on tech founder, agentic infrastructure architect and the vision behind Mel.

Follow on LinkedIn

Get started

Try the agentic terminal for teams.

The Mel terminal is free to download, no account needed. The AI agent is free on your own provider key — 1,500 hosted-AI credits a month on Pro.