Why Pasting an Assertion Failure Rarely Fixes Code
An assertion failure says the output was wrong, not which line made it wrong.
Reviewed by Abhijith N M · 24 October 2026 · Editorial standards
Your test fails with `AssertionError: expected [3, 1, 2], got [1, 3, 2]`. You paste that into the chat and ask the model to fix it. It rewrites something, you run it, it fails again. Five rounds later you are still there. A paper on arXiv looks at why. The authors ran iterative repair — send the error back, get a new program, repeat — across four Qwen2.5 models. What survived all that repair was mostly assertion failures: 79% of leftover failures on BigCodeBench, all of them on HumanEval, 93% on LiveCodeBench. The loop was working. It just wasn't reaching the faults that mattered. The argument is about information. A traceback from a crash points at a line: the interpreter stopped there. An assertion failure points at a comparison. It tells you the final value was wrong. It does not tell you which earlier line computed the wrong intermediate value. The model sees a mismatch and has to guess where in the program it came from. Guessing is what it does when it rewrites the whole function and hopes. The authors propose Breakpoint Debugging: hand the model the program with the runtime values of its variables written inline, the way a debugger shows them when you stop at a breakpoint. Now the model can see that `i` was 2 when it should have been 0, instead of inferring it. On BigCodeBench tasks that five repair attempts had failed, five more generations with this handoff fixed 26.7% versus 22.4% for simply resampling. It also cut resubmissions of unchanged code from 28% to 8% — the model had something new to act on. The limits are real. On LiveCodeBench, fresh sampling did better (6.5% against 4.9%), and Breakpoint Debugging gave no gain even on public tests. The authors' reading: a trace helps when the test exposes a failing input and the bug is an implementation slip. Otherwise, resample.
Why Pasting an Assertion Failure Rarely Fixes Code — Visual Breakdown
Paste the assertion failure
- ✓Model sees: expected [3,1,2], got [1,3,2]
- ✓No line number, no variable values
- ✓Model guesses which line is at fault
- ✓Often resubmits near-identical code (28% unchanged on BigCodeBench)
Paste the state at the failure
- ✓Model sees: program annotated with runtime values
- ✓Shows i == 2 where 0 was needed
- ✓Fault location is visible, not inferred
- ✓Fewer unchanged resubmissions (8% on BigCodeBench)
def rotate_left(xs):
out = xs[:]
for i in range(len(out)):
out[i] = xs[(i + 1) % len(xs)]
return out
# What you paste today:
# AssertionError: expected [3, 1, 2], got [1, 3, 2]
# What Breakpoint Debugging pastes instead:
# i = 0 out[0] = 1 xs[(0+1) % 3] = xs[1] = 1
# i = 1 out[1] = 3 xs[(1+1) % 3] = xs[2] = 3
# i = 2 out[2] = 2 xs[(2+1) % 3] = xs[0] = 2
# The values show the rotation direction is wrong, not the final compare.Quick Concept Check
Test your understanding in 15 seconds
According to the paper, why does an assertion failure give a model less to work with than a crash traceback?
Related Concepts
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.