Tools · 2026-09-29

You stream the answer to the user.

Only after the stream ends do you notice the model actually wanted to call a tool.

  1. AKeep streaming, and if a tool call shows up afterwards, append its result to the text already shown and let the user read the combined answer
  2. BRead the stream’s stop reason and handle the tool turn BEFORE treating any text as the final answer
  3. CRaise max_tokens so the model finishes its thought
  4. DAlways make a separate non-streaming call first to decide about tools

Answer: B

Read the stream’s stop reason and handle the tool turn BEFORE treating any text as the final answer

Why

A stream is not the answer, it is a transcript of a turn that has an outcome. The stop reason is that outcome; a doubled call pays twice for information the first stream already carried.

More on this topic

More on Way of the Agent

Real situations from building agents - with the answer and why.

Solve a new one every day on the Path