Sub topic 13
When to re-run, narrow the task, or take over
This chapter covers the decision you face after reviewing an agent's diff and finding problems. You can accept the change, revert part of it, re-run with a narrower task, or finish the work yourself. It assumes you can use Git branches, staging, and git restore, and that you have already reviewed a multi-file diff using the earlier chapters of this tutorial.
Why this is a decision, not a habit
After a review you rarely get a clean "accept" or "reject". Most diffs are mixed: some hunks are right, some are wrong, and some are unclear. Each response has a cost.
- Steering with feedback costs a few minutes and one more round of review.
- Re-running costs a fresh review of a new diff, and the new run may introduce different mistakes.
- Taking over costs your own time, but the result is code you wrote and understand.
The goal is to reach a correct, reviewed change with the least total effort. Picking by habit, such as always re-prompting or always fixing by hand, wastes effort in the cases where the other option is cheaper.
The four options
| Option | What you do | Best when |
|---|---|---|
| Accept | Commit the change as is | Every hunk is correct and your own checks pass |
| Partially accept | Stage good hunks, discard the rest | Good and bad hunks are separable |
| Steer or re-run | Send corrective feedback, or discard the work and start again with a tighter task | The problems share a cause that a clearer instruction can remove |
| Take over | Finish the change by hand | The remaining work is small, subtle, or the agent keeps failing at it |
Steering within the same session keeps the agent's context. A re-run from a clean baseline discards that context, which is useful when the context itself is the problem.
Signals that favor each choice
Accept or partially accept
Choose these when the defects are local. A wrong edit in one file, a skipped test you can restore, or one out-of-scope file you can revert do not justify discarding the rest. Partial acceptance relies on the clean baseline from earlier in the tutorial. Because the branch started clean, everything in git status is the agent's work and you can sort it hunk by hunk.
git add -p # stage only the hunks you accept
git commit -m "Rename config loader (reviewed agent changes)"
git restore -p . # interactively discard remaining unwanted hunksRun your own checks after the commit, not before. The commit contains exactly what you accepted, so test results describe that content.
Steer in the same session
Choose feedback when the agent understood the task but made a specific, nameable mistake. Examples:
- It edited a file outside the scope.
- It weakened one test.
- It used a function name that does not exist and the correct one is easy to state.
A good correction confirms what is right, names each problem with its file, bounds the next edit, and asks for a verifiable report.
The change to src/config/loader.py is correct. Two problems remain:
1. You edited src/billing/invoice.py, which is outside this task. Revert that file.
2. tests/test_loader.py now skips test_missing_file. Restore the test and fix the code so it passes.
Do not change any other files. When finished, run the project's test suite and report the exact command and its result.If you must send the same correction twice, the feedback is not working. Treat the second identical failure as a signal to change approach rather than repeat the message more firmly.
Narrow the task and re-run
Choose a re-run when the problems come from the task, not from a single slip. Typical signs:
- The diff touches many unrelated areas because the request was broad.
- The agent made different assumptions in different files, so the pieces do not fit together.
- Fixing the diff would take longer than reviewing a new one.
- The conversation has accumulated wrong assumptions that the agent keeps building on.
Narrowing means splitting the work into steps that can each be reviewed alone. A request such as "rename the config loader and update all callers" can become two runs: first rename the function and its definition, then update callers in one package at a time. Each run gets its own commit, so a later failure never puts earlier good work at risk.
When you re-run, change something. Re-sending the same prompt usually gives a similar result. Useful changes include:
- Listing the exact files the agent may edit.
- Stating the definition of done, such as which command must pass.
- Adding the fact the agent got wrong the first time.
- Reducing the number of files per run.
Take over
Choose to finish by hand when:
- The remaining fix is a few lines and you already know them.
- The problem needs judgment the agent lacks, such as a subtle concurrency rule or a business decision.
- Two or three rounds of feedback have not moved the result closer.
- The agent keeps reintroducing a defect you have already corrected.
Taking over is not a failure. A hand edit on top of the agent's good hunks is often the fastest path. Commit the agent's accepted work first, then make your own changes in a separate commit, so history shows which part came from where.
Handling the discarded work
Before you throw away a run, decide whether anything in it is worth keeping. Reverting everything is easy, but you may lose a correct test or a useful helper.
Safe ways to discard:
- Commit or stash anything you want to keep.
- Prefer discarding on the agent's branch, not on your main branch.
- Use
git restorefor specific files or hunks. Usegit switchto a fresh branch from the starting commit for a full re-run.
git stash push -m "agent run 1, partial" -- tests/ # keep the useful test changes
git restore . # discard tracked-file edits
git clean -n # preview untracked files firstgit clean deletes untracked files permanently, so always run it with -n first and read the list. Also remember that git restore . only affects tracked files. New files the agent created remain until you remove them.
A decision flow
The flow below is a rule of thumb. It orders the choices by cost, trying the cheapest effective one first.
Failure modes in the decision itself
- Sunk cost. You spent twenty minutes reviewing the diff, so you try to rescue it. Judge the remaining work, not the time already spent.
- Endless steering. Each round fixes one thing and breaks another. After two rounds without convergence, narrow the task or take over.
- Re-running without changing anything. You get a new diff with new problems and no new information.
- Taking over too early. You fix by hand a problem that one sentence of feedback would have solved, and the lesson is not recorded for later runs.
- Taking over without recording. If the agent made the same mistake you corrected by hand, and it will likely recur, add it to the project instructions so later runs avoid it.
- Accepting because a retry is annoying. Fatigue is not a check. Your own tests, type checks, and linters decide acceptance.
Setting limits in advance
Decide your limits before the run, when you are not tired of it. A workable set:
- At most two rounds of feedback on the same problem.
- At most one re-run with the same scope. A second re-run must have a narrower scope.
- If the diff exceeds the size you can review carefully, split the task instead of reading faster.
These numbers are starting points. Adjust them to your team and to how costly a missed defect is in the code being changed. Changes to billing, authentication, or data migrations deserve a lower tolerance for rescuing a flawed run.
Worked example
You asked an agent to rename load_config to read_settings across a project. The review shows:
- Definition and 14 call sites updated correctly.
src/billing/invoice.pyedited with an unrelated formatting change.tests/test_loader.pyhas a new@pytest.mark.skipon one test.- Your tests fail in a module the agent did not touch.
Applying the flow:
- The rename hunks are correct and separable, so stage them with
git add -pand commit. - Discard the billing edit with
git restore src/billing/invoice.py. - The skipped test is a specific mistake, so send bounded feedback: restore the test and fix the code.
- The failure in the untouched module has an unclear cause. Look at it yourself. You find that it reads the old name through a string-based lookup that the agent could not see. This is a small, judgment-based fix, so take over: change the string and commit it separately.
The final history has the agent's rename, your fix, and no unrelated edits. Each decision was driven by the cause of the defect and the cost of fixing it.
Exercise
An agent was asked to update 40 files across five packages. The diff has inconsistent assumptions between packages, and you have already sent two rounds of feedback that each fixed one package and broke another. What do you do next, and why?
Show answer
Stop steering and narrow the task. Commit any hunks you have reviewed and verified, then re-run from that clean baseline with one package per run, each with a list of allowed files and a command that must pass. Two rounds without convergence show the problem is the breadth of the task and the accumulated context, not one fixable slip. Taking over by hand is reasonable only if the remaining work turns out to be small.
Exercise
After partially accepting an agent's changes you run git restore . and then git status --short. A new file src/config/helpers.py still appears. Why, and what should you do before deleting it?
Show answer
git restore . only reverts tracked files, and the new file is untracked. First read the file to decide whether it holds anything worth keeping. Then run git clean -n to preview the deletion, and only after checking the list run git clean -f or delete the file by name.
Exercise
You corrected the same out-of-scope edit by hand in three separate runs. What should you do besides fixing it again?
Show answer
Add a rule to the project instructions that names the boundary, for example that billing code must not be edited during config tasks. Repeated manual correction means the agent lacks persistent guidance, so recording it prevents the defect in later runs.