Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Debugging with an Assistant  ›  Capstone Project

Break the Fix Loop

Debugging 15 minAfter two failed fixes, stop prompting, revert to the last good commit, narrow the bug to one test and gather real evidence before trying again.

Break the Fix Loop

After settle-up went in, Kitty's balances started going wrong. The first fix made Asha's balance right and Meera's wrong. The second fix made Meera's right and Ravi's wrong. You are about to type "still broken, please fix". That is the fix loop: every lap adds code built on a guess, and the pile of guesses grows.

The rule

Two failed fixes means stop: revert, narrow, gather evidence, then try again.

The assistant will keep producing fixes for as long as you keep asking. Each attempt is a guess about the cause, and failed guesses leave code behind. Breaking the loop takes four moves:

  • Revert. Go back to your last good commit. Reason about one known problem, not three layers of attempted fixes.
  • Narrow. Reduce it to one failing test with the smallest case.
  • Gather evidence. Look at what the code actually does, rather than guessing. The simplest tool is a temporary print of the values at the suspect line:
print("expenses:", expenses)
print("payments:", payments)
print("balances:", balances)
  • Try again, differently. Ask the assistant for causes rather than code: "List three possible causes and how to test each one. Do not change any code yet." Then test them. Or take the wheel and work the case by hand.

The shortcut

Two strikes, then evidence. After two failed fix attempts, no more fix prompts until you have something new: a printed value, a narrowed test or a confirmed cause.

Escaping Kitty's settle-up loopStep 1 of 4
  1. Strike two: stop

    The second fix moved the error from Meera to Ravi. Stop prompting fixes.

The clue was in the symptom all along: a payment between Ravi and Asha changed Meera's balance. Evidence made that visible; more guessing would have buried it.

Drills

Answer fast — trust the rule.

quick drill

Your second fix attempt has failed. What does the rule say?

quick drill

Why revert instead of fixing on top of the failed attempts?

quick drill

Which of these counts as new evidence?

quick drill

After Ravi settles up with Asha, Meera's balance also changes. What is the strongest clue?

quick drill

Which request helps most when you are stuck in a loop?

Remember

  • Rule: two failed fixes means stop: revert, narrow, gather evidence, then try again.
  • Shortcut: two strikes, then no fix prompts until you have new evidence.
  • Trap: "still broken, please fix", which is one more guess piled on the others.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainEscape the loop

In Kitty, each fix the assistant makes corrects one flatmate's balance and breaks another's. Explain how you would get out of this loop: when you stop, what you revert, what evidence you gather, and what you ask the assistant next.