1. Which step of a turn runs the tools the model asked for?
- Call
- Act
- Append
- Inspect
Show answer
Answer: Act
Call asks the model, inspect reads its stop reason, act executes the tools, and append records results.
Lesson: The Structure of a Turn
27 questions from the Agent Loops, Stop Conditions and Token Budgets course, each with the correct answer and an explanation. Try to answer before you open the answer.
Answer: Act
Call asks the model, inspect reads its stop reason, act executes the tools, and append records results.
Lesson: The Structure of a Turn
Answer: The reply may be cut off at your output limit
It means generation hit the output cap, so the content can be incomplete.
Lesson: Reading stop_reason
Answer: 55,000
Because history is resent, the total is 1,000 × (1 + … + 10) = 55,000.
Lesson: Why Cost Grows Faster Than Steps
Answer: Scattered checks are easy to forget or apply inconsistently
One owner of the limits keeps checks consistent and the stop reason easy to report.
Lesson: A Loop with Every Guard
Answer: The test suite passes
A passing test suite is evidence code can check; a claim is not.
Lesson: Defining "Done"
Answer: Wall-clock time limit
A hanging call uses few steps and tokens but a lot of real time.
Answer: The same tool call with the same arguments repeating
It counts identical recent calls and flags a loop that is going nowhere.
Lesson: Detecting No Progress
Answer: Between turns, at a safe point
Checking between turns avoids leaving half-finished side effects.
Lesson: External Stops and Cancellation
Answer: The usage object in the response
The API reports exact input and output token counts for each response.
Lesson: Counting Tokens
Answer: If history fills the window there is no room left to answer
Input and output share the window, so the reply needs guaranteed room.
Lesson: Allocating the Context Window
Answer: Allows longer replies but does not force them
It raises the ceiling on reply length; the model still stops when it is done.
Lesson: Setting max_tokens Wisely
Answer: After the stable prefix
Only an identical prefix can be reused, so volatile parts must come after it.
Lesson: Prompt Caching
Answer: It is resent on every later turn
History is resent each turn, so a big result keeps costing tokens until removed.
Lesson: Clipping Tool Results
Answer: The original task
Losing the original goal makes the rest of the work aimless.
Lesson: Summarising Old Turns
Answer: Only a short reference such as the path and description
A small handle keeps context lean while the data stays available on demand.
Lesson: Offloading to Files and Memory
Answer: Silent overspend
Only a total budget notices cost that accumulates across many individually fine steps.
Lesson: A Catalogue of Loop Failures
Answer: 429 Too Many Requests
Rate limits are temporary; the others will fail the same way until the request changes.
Lesson: Retries and Exponential Backoff
Answer: To detect a model that is thrashing and not recovering
A run of failures without a success means more retries are unlikely to help.
Lesson: Tool Errors and Thrashing
Answer: So the model writes a summary instead of starting more work
Without tools the only possible output is the final text.
Lesson: Forcing a Final Answer
Answer: Resuming may repeat the last step
If the last step ran but was not recorded, a second run must not cause duplicate effects.
Lesson: Checkpoints and Resume
Answer: Goal, what was tried, last error, state and a suggested next step
A structured summary lets a person act without reconstructing the history.
Lesson: Escalating to a Human
Answer: To see how runs end and which limits are being hit
Stop reasons reveal patterns such as frequent token-budget stops that point to a context problem.
Lesson: Metrics That Matter
Answer: It makes tests fast, free and repeatable
Scripted replies make the loop's logic deterministic and cheap to verify.
Answer: Large page text is resent every turn and inflates cost
Big tool results are resent on every later turn, so bounding them controls total cost.
Answer: Wall-clock timeout
Slow or hanging tools consume time, not steps or tokens.
Answer: stop_reason "max_tokens"
A reply that hit the output cap is truncated, and the loop must treat that case explicitly.
Answer: A total token or cost budget checked every turn
Only a cumulative budget notices cost that adds up across many small steps.