Lesson 25 / 25

Revision: Cheat Sheet and Self-Check

Review the loop, stop-condition and budgeting essentials from the whole course.

Cheat sheet

Turn = call, inspect, act, append. Stop reasons: end_turn, tool_use, max_tokens, stop_sequence. Cost grows with the square of turns because history is resent. Limits: steps, time, tokens, money, plus repeat detection and cancellation. Done should be verifiable. Tokens: read usage, reserve output space, cache the stable prefix. Context: clip, summarise, offload. Failures: repeat, thrash, drift, bloat, overspend. Ending: wrap-up call, checkpoints, structured handover. Quality: metrics per run, tests with a scripted model.

Questions interviewers ask

Be ready to explain: why agent cost grows faster than the number of steps, the difference between a hard limit and a no-progress check, why max_tokens handling matters, how prompt caching works, how you would stop a runaway loop safely, and how you would test a loop without calling a real model.

Quick check: A run uses 4 steps and few tokens each, yet takes 10 minutes. Which limit would have caught it?

  • Step limit
  • Token limit
  • Wall-clock timeout
  • Cost limit
Answer

Wall-clock timeout — Slow or hanging tools consume time, not steps or tokens.

Quick check: The loop returns half a sentence as the answer. What did it most likely skip checking?

  • The API key
  • stop_reason "max_tokens"
  • The operating system
  • The tool names
Answer

stop_reason "max_tokens" — A reply that hit the output cap is truncated, and the loop must treat that case explicitly.

Quick check: Which combination best prevents silent overspend?

  • Only a step limit
  • A total token or cost budget checked every turn
  • A longer system prompt
  • Disabling logging
Answer

A total token or cost budget checked every turn — Only a cumulative budget notices cost that adds up across many small steps.