Chapter 6: Termination

A run ends in one of these ways: a final answer, a step limit, a token budget, a timeout, or loop detection. Every run returns a RunResult with the reason, so failures are easy to read.

Figure 6.1. Each way a run ends maps to one StopReason. The chapter does not fix an order for the checks; this order is one reasonable choice. APPROVAL_TIMEOUT and REJECTED come from the approval path in Chapter 9.
public record RunResult(String answer, StopReason reason, int steps) {
    public enum StopReason { FINAL_ANSWER, STEP_LIMIT, TOKEN_BUDGET, TIMEOUT, LOOP_DETECTED, APPROVAL_TIMEOUT, REJECTED }
}
docs