Lesson 4 of 8 · 3 min read
Budgets, Loops and Termination
Long-running agents need termination guarantees at three levels. Within a run, budgets for money, time, steps and per-tool use are recorded in durable state so a restart cannot reset them, and progress is measured by new information or completed work rather than by step count, which catches loops whose steps all look slightly different. Across runs, fleet-level limits and spend anomaly alerts stop a bug that is cheap per run but runs ten thousand times. And every limit ends the run cleanly, with a reason, a partial result and a record.
Get full Premium access · $25
All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.
6 months · One payment · No auto-renewal
Practise it as an interviewer asks it
What is context engineering, and why does an agent need it when the model already has a 200k-token window?What does it mean for an agent to be durable, and why can't a normal loop just retry after a crash?Write the agent loop on the whiteboard, then list every way a run can end.Your agent has a 200k-token window and falls apart at 55k. Why, and what do you change?A worker crashes after the payment call succeeds and before the result is saved. Design recovery.Human approval may arrive three days later. Design the wait.