Chapter Ten · Debugging With an Agent

Debugging With an Agent

Kai's double waitlist offer from Chapter 2, fixed the way this book teaches: a failing test before any fix, evidence instead of a description, a cause that is a mechanism, a session stopped before it circles, and the commit that broke it found by a search the agent runs and a test decides.

5 topics

A bug is where working with an agent is most tempting and most dangerous. It is tempting because the agent reads code faster than you, never tires of a stack trace, and always has a fix to offer. It is dangerous for the same reason: the fix always arrives, it always sounds right, and on an intermittent bug nothing tells you whether it worked until the next incident, weeks later.

This chapter takes the double offer from Kai's waitlist, the bug nobody could trace in its third week, and runs it through the whole method. The mechanism, as the chapter establishes it, is a race. Two paths can offer a freed place: the cancellation request, and a sweep that runs every 30 seconds to pass on expired 15-minute holds. Each reads "one free place, no active offer" and then writes an offer, as two separate steps. When both read before either writes, two members get one place. Kai's earlier fix, a two-second pause in the sweep, made that rarer and left it possible.

The five pages follow one debugging session from start to finish. A test that forces the race on every run comes first, because without it no fix can be judged. Then the evidence the agent needs, scrubbed of anything personal, and a way to choose among its hypotheses. Then the first plausible fix refused, and the real one found by asking why until the answer is a line range and a missing guarantee. Then what to do when the agent starts going in circles. And last, the commit from the waitlist's second week that removed the guarantee, found by a binary search that the agent drives and the test judges.

One debugging session, and the question each step answers
Reproducecan we make it happen?
→
Evidencewhat did it record?
→
Root causewhich mechanism?
→
Bisectwhich commit?

Topics in This Chapter