Order the stream parts emitted by streamText for one tool call plus a final text response
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
start opens the stream, then preamble text-deltas, then the model's tool-call, then your tool-result, then the final text-deltas after the tool returns, then finish closes the stream.
Imagine a waiter taking your order. First they say 'good evening' (start). They suggest 'maybe an appetizer' (preamble text). They walk to the kitchen and shout the order (tool-call). The kitchen sends back a plate (tool-result). Then they describe the dish to you (final text after the result). Finally they bow and step away (finish). Reordering steps in real life would be confusing; the same is true for a streamText pipeline driving a chat UI.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 to 8 min: the six canonical parts + why each ordering rule is forced + tool-call argument streaming + multi-tool extensions + UI rendering pattern with useChat.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Placing tool-result before tool-call, or placing the final text-deltas before the tool runs. Final text always follows the tool-result because the model needs to read it.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.