max-tokens is the observed finish reason; consecutive useless repetition is a separate content-shape diagnosis.Contain the live cost first.
- 01Click Stop once and wait for a durable aborted Turn.
- 02Record whether repetition is answer text, reasoning, tool arguments, or tool output.
- 03Capture raw deltas, route, request id, usage, finish reason, and maxTokens.
- 04Inspect durable retry events before replaying a deterministic failure.
Separate four failure shapes.
EMPTY_RESPONSE is retryable by default.
Valid output reached a cap; fix budgeting.
One unit loops inside one attempt; guard the stream.
Multiple steps or calls need loop containment.
Detection and recovery are separate decisions.
Do not run a prose heuristic over tool-call JSON; evaluate reasoning separately.
Emit one experimental stable classifier; nothing follows terminal finish.
Alpha.1 normal mode allows five ordinary transient retries, but no built-in degeneration code.
Cancellation crosses browser, Session, Agent, adapter, and provider boundaries. Report observed usage or uncertainty.
Primary evidence.
- Repeated zeros report #4841
- Official guard proposal #3480
- alpha.1 streaming contract
- alpha.1 retry defaults
Evaluate the guard before making it policy.
The complete guide includes live containment, evidence fields, channel rules, threshold experiments, finite retry configuration, UI semantics, billing caveats, and acceptance gates.
Read the complete guide