When a Coding Agent Keeps Expanding the Task: Fix the Workflow Before Switching
The quick answer
At that point I'd stop the run, save the useful changes and restart with one clearly defined result.
Build your budget shortlistIn this guide
You ask for a bug fix. The agent starts reorganizing the test suite, finds another problem and proposes a refactor. An hour later, the original bug is still there. At that point I'd stop the run, save the useful changes and restart with one clearly defined result.
If a cleaner task still leaves you considering a switch, use our Codex and Claude Code comparison to review the subscription trade-offs alongside the workflow problem.
Before adding another page of instructions, decide what the agent needs to finish next.
Why repeated corrections stop helping
This can happen even when you're watching closely. You interrupt, correct the plan and resume, only to find the next run taking another detour. Adding more instructions can make the task harder to follow without making it easier to finish. The missing piece is often a clear answer to: what would count as done?
Tell it what done looks like
Name the result, the work it covers and the check that will show it works. For example:
Make the existing checkout smoke test run locally against the seeded test account. It must cover sign-in, adding one item and reaching order confirmation. Fix defects that prevent those steps. Report unrelated findings separately. Finish when those steps pass and the changed code has been reviewed.
Adapt the steps to your project. The important part is that you and the agent can both tell when the job is finished.
Contrast that with “audit everything and keep improving until polished.” That instruction can make every new finding relevant, leaving no stable point at which to stop. OpenAI's Goals guidance emphasizes defined outcomes, constraints and completion checks; it does not make an indefinite run evidence of success. Official Goals guidance.
Sort findings before authorizing more work
Use a short ledger with three categories:
| Finding | Treatment during this task |
|---|---|
| Directly prevents the acceptance case | Investigate and fix within the current scope |
| Introduced by the current change | Repair before considering the task complete |
| Pre-existing or unrelated improvement | Record separately with evidence and impact |
This separates finishing a feature from maintaining the whole repository. It also gives you a way to reject unnecessary work without asking the agent to ignore a real problem. A memory investigation might be essential when the test runner crashes from resource exhaustion. It is a distraction if the runner works and the task is merely to correct a button interaction.
Know when to stop testing
Name the checks that matter before implementation. After a check passes, repeat it only if a relevant change or failure justifies another run. If the same check fails repeatedly with the same evidence, require a new hypothesis before another attempt.
A failed network request is not permission to refactor the networking layer. First establish whether the problem is local configuration, a service outage, missing credentials or application code. A diagnosis should change the next action; otherwise the task is simply cycling.
Keep the evidence small enough to review: the failing case, the changed files, the successful check and remaining limitations. Hundreds of generated notes can hide the absence of a working result.
Recover without losing useful work
Inspect the current diff before reverting anything. Separate changes that directly satisfy the acceptance contract from experiments and unrelated cleanup. Save a checkpoint or branch so the decision is reversible, and avoid wholesale resets that could remove your own work.
Start a fresh task when the conversation is dominated by abandoned approaches. Hand over the current requirement, relevant files, accepted decisions, one reproducible failure and the stopping condition. Do not make the next agent reconstruct twenty days of transcript unless those details are necessary.
If you use two agents, give one implementation ownership and the other a bounded review. Parallel edits to the same files can create another class of failure that looks like poor reasoning but is really coordination trouble.
When switching products becomes reasonable
Switch after a clean, bounded retry still fails in a repeatable way, or when the tool lacks a capability necessary to verify your result. Give the alternative the same small task and starting state. Judge the resulting behavior, not the confidence of its explanation.
A switch is worth trying when the same bounded task keeps failing after you've supplied the necessary setup and a clear pass condition. Give the alternative that task from the same starting point. Keep whichever helps you get to a result you can inspect, rather than another plan to review.