Skip to content

Lesson 4 of 9 · 5 min read

Streaming Inside the Loop

A streamed model response arrives as server-sent events carrying deltas: fragments of text, and fragments of tool-call arguments that the harness must reassemble by index before it can dispatch anything. Streaming cuts time to first token for prose turns and changes nothing for tool turns, where the harness has to wait for the complete call anyway. What an agent's client actually needs is a stream of loop events (step started, tool requested, result arrived, final answer, stopped with reason), produced by the loop and consumed by any UI, and a cancellation path that stops the producer rather than just closing the tab. Parsers must handle split UTF-8 bytes, events split across chunks and the final usage event that arrives after the last token.

Reviewed By the AIAgentInterviews editorial team
free sign-in, no card required

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons