Session 5. A deterministic mini-agent — Fri 18 Sep

Quick quiz (ungraded)

Q1: Why does the lab give run_loop a written plan instead of asking a model what to call next?

  • Speed is not the issue. FakeLLM answers instantly and still could not be made to spin on demand.

  • Correct. You cannot write a test that says 'and now the model repeats itself'. With a plan, the repetition and budget exits are reachable every run.

  • It needs one for the decide beat. The plan stands in for that one beat so the other three can be tested.

Q2: A four-step plan runs under budget=2. What must be true of the receipt?

  • Correct. The budget is checked before the call, so the call you were not allowed to make is never paid for.

  • That records four calls, which means four calls ran. The budget is a cap on spending, not a label applied afterwards.

  • The result was discarded; the latency and the cost were not. Check before the call.

Q3: The loop sees list_documents(tag="retrieval") twice in a row and stops. Why is that its own exit rather than a job for the budget?

  • It would stop it after paying for the whole budget, and the receipt would then blame a budget that was never the problem.

  • Correct. Two exits, two diagnoses. The receipt has to say what actually went wrong.

  • Both are the app's to handle. The distinction is what the receipt tells the person reading it.

Q4: A tool raises ToolError on the third call of a run. What does the finished loop return?

  • The caller sees a traceback and loses the two steps that succeeded. A raised error is not a receipt.

  • Correct. The successful work survives, and whoever reads the receipt knows which tool went away.

  • That reports the wrong exit and puts a failure where an answer belongs. Only an answer step sets answer.

Q5: Why does every exit return all four receipt keys, even the ones it does not use?

  • Correct. A shape that changes with the outcome forces a branch on every read, and the forgotten branch is the one that mattered.

  • It does not. This is a design choice about the contract, not a serialization constraint.

  • steps varies with the run. It is the keys that stay fixed, not the size.