Skip to content

devlog/agent-loops/when-to-interrupt-a-coding-agent-8.md

When to Interrupt a Coding Agent

Start with a task that has a clear stopping point

The hardest part of using a coding agent is often deciding whether its current mess is productive exploration or a wrong turn. I use a simple rule: let the agent run while it is gathering evidence, editing related files, or executing tests. Interrupt it when it starts repeating itself, expanding scope, or changing behavior without a clear reason.

For this walkthrough, begin in a clean branch and give the agent a bounded task. These commands create the branch and record the starting state:

git switch -c agent-payment-validation git status --short git log -1 --oneline

Before starting, configure the relay once in the shell. Fluxo provides one key and one base URL, https://api.fluxorelay.com, for Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. It works with Claude Code, Codex, Gemini CLI, and OpenAI SDK clients.

export FLUXO_API_KEY='replace-with-your-key' export ANTHROPIC_API_KEY="$FLUXO_API_KEY" export ANTHROPIC_BASE_URL="https://api.fluxorelay.com" export OPENAI_API_KEY="$FLUXO_API_KEY" export OPENAI_BASE_URL="https://api.fluxorelay.com"

Let the agent run while its evidence keeps improving

Ask for a focused change with explicit verification. I usually start Claude Code with a model suited to repository work, such as Claude Sonnet 5.5:

claude --model "Claude Sonnet 5.5" "Add server-side validation for expired payment methods. Inspect the existing tests first, make the smallest compatible change, run the relevant test command, and summarize changed files."

While it works, inspect its output without grabbing the keyboard immediately. In a second terminal, watch the repository and recent agent output:

watch -n 2 'git status --short' tail -f .agent-output.log

If the agent is reading validation code, finding a matching test, and then running that test, let it continue. A temporary failed test is useful evidence when the failure narrows the problem. The same applies when it asks for a missing type definition or discovers that the repository uses a shared helper instead of a local implementation.

  • Let it continue when each action answers a specific question.
  • Let it continue when changes remain inside the requested feature boundary.
  • Let it continue when tests provide increasingly precise feedback.

Interrupt immediately when the work loses its shape

Interrupt when you see repeated edits to the same lines, broad refactors unrelated to the request, generated files changing unexpectedly, or commands that keep failing for the same reason. I also stop an agent before it edits migrations, deployment configuration, or authentication code without explaining the impact.

Use the terminal interrupt first: — Ctrl-C

Then capture the current state before giving new instructions:

git status --short git diff --stat git diff --check git diff -- payments/validator.ts tests/payments/validator.test.ts

The last command should name the files that actually matter. If the agent touched more files, list them explicitly and ask it to explain every one. Do not erase the work immediately; the diff tells you whether the agent found a useful partial solution.

  • Interrupt when repeated attempts produce the same failing output.
  • Interrupt when the agent changes unrelated files without permission.
  • Interrupt when its explanation no longer matches the visible diff.

Restart with a smaller prompt and preserved evidence

After stopping, write down the failure in one sentence. For example: “The validator now rejects valid cards because the expiration comparison uses local time.” Give that observation back to the agent with the exact test output and a narrower next step.

claude --model "Claude Haiku 4.5" "Review the current diff only. The expiration comparison uses local time and rejects valid cards near month boundaries. Do not refactor unrelated code. Propose one fix, add or update one focused test, then run the payment validator tests."

Using Claude Haiku 4.5 for this recovery pass keeps the task quick, while a larger model such as Claude Opus 5.5 can be useful when the repository needs deeper architectural reasoning. Fluxo bills per real token, including cache reads and writes, with no monthly fee, so the cost of a recovery pass follows the work performed. Users can also earn a referral share when invited developers pay.

Finish only after the diff and tests agree

When the agent reports success, verify independently. Ask for the final diff, then run the project commands yourself:

git diff --check npm test -- --runInBand git status --short

I let an agent run longer when tests, files, and explanations agree. I interrupt when any one of those three starts drifting. That habit keeps the agent useful without turning supervision into constant hovering.

If this workflow fits how you code, you can create a Fluxo account and use the same relay setup with your editor and terminal tools.

Next in the buffer

Sign up in a minute and get credit to try every model mentioned here. Sign up →