result.run.stop_reason and normalized usage after completion to distinguish a budget stop from a normal model finish.
Stopping is a bounded outcome, not automatically an exception. Decide which reasons should be successful, retryable, or shown to the user.Build
Stop conditions
Bound Ruby agent runs by steps, tokens, cost, duration, tools, or finish reason.
Combine stop helpers to keep autonomous work inside application budgets.
Tool-call and finish-reason conditions are also available. Inspect
Last modified on July 26, 2026