Skip to content

Lesson 7 of 9 · 6 min read

Timeouts, max_tokens and Deadlines per Step

The latency of one model call is roughly a fixed overhead, plus the input tokens divided by the prefill speed, plus the output tokens divided by the decode speed. Inside a loop that arithmetic repeats per step, so a run has a deadline, each step gets a share of it, and max_tokens for a step follows from the time left rather than from a default. A reserve is held back for a final wrap-up call with no tools, so a run that is out of time still returns a grounded partial answer instead of nothing. Timeouts are classified as transient and retried within the run budget, a stop reason of length triggers a continuation or a retry with more room, and a reply cut off mid-JSON is detected by the stop reason and never repaired into a wrong object.

Premium lessonReviewed By the AIAgentInterviews editorial team
Get full Premium access · $25

All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.

6 months · One payment · No auto-renewal

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons