All courses

When to stop, reset or take over

Recognise a session going bad: the agent repeats a failed fix, the diff keeps growing, suppressions pile up or it contradicts itself. Then revert to a clean commit, start a fresh session with a distilled summary, or do the change yourself.

Builds on: Long sessions: lost instructions and drift, Patching the symptom instead of the cause

Read it card by card Start the whole course

Third try, same fix, bigger diff

You asked the agent to make the report build pass after a type error in `src/report.ts`. Forty minutes later it has tried converting the date three times in different words. The diff touches seven files. Its latest message says `r.date` is a string, two turns after it said it was a number. The build is still red. Your fingers are on 'try again'. Is that the right move?

Why more turns make it worse

Every failed attempt stays in the context, and the agent conditions on it. Its own wrong theory now reads like evidence, so it rewords the same fix. It still aims at the proxy signal (build green). While the cause stays hidden, it widens the net: casts, ignores, guards, edits in more files. Each 'try again' adds pollution. Later cost: a sprawling diff mixing the fix with leftovers, and silencers hiding real errors.

Four tells, then revert and choose

Stop when you see: - the same fix again, reworded - the diff grows while red checks don't shrink - suppressions pile up (`as any`, `@ts-ignore`, `# type: ignore`, `#[allow]`) - it contradicts its earlier diagnosis or a rule you gave it Then **revert** to the last clean commit. Keep notes, not code. After that, either: - **Restart** in a fresh session with a distilled summary, or - **Take over** when you can see the cause and the fix is a few lines.

A reset that carries facts, not history

You run `git reset --hard` to the commit before the session, or `git stash` to set the mess aside. Also delete any new files the agent created, because neither command removes them. Then you open a fresh session: > Goal: `rows()` type-checks with no casts or ignores. Fact: `r.date` is `string | number` because the CSV loader declares it so. Tried: casting, skipping rows. Both rejected; rows must never be dropped. Done: `npm run build` green and the tests in `report.test.ts` pass. Now the agent starts from the real type and where it comes from, not from its old guesses.

The diff after three attempts

`as any` alone already silences the type error. So the `@ts-ignore` above it is a leftover from an earlier attempt: two silencers on one line mean attempts were stacked, not replaced. `if (!d) continue` drops every row whose date fails to parse. Later cost: report totals quietly missing rows, and the `string | number` mismatch from the loader still unresolved for every caller. This is the moment to revert, not to ask for attempt four.
// TypeScript
--- a/src/report.ts
+++ b/src/report.ts
@@ -20,4 +20,6 @@ export function rows(
   for (const r of data) {
-    const d = parseDate(r.date);
+    // @ts-ignore
+    const d = parseDate(r.date as any);
+    if (!d) continue;
     out.push(fmt(d, r.amount));
   }

Stop early, restart clean

These four tells mean the context is polluted, and more turns will make it worse: - repeated fixes - a growing diff - piling suppressions - self-contradiction Revert to a clean commit. Then either restart with a short summary of goal, facts, dead ends and the done check, or write the fix yourself.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.