Stream modes at their source, and the v3 projection buffer
Read one v3 projection per message, or the raw events, because a loop that reads reasoning first showed a reasoning model's answer 8.8 to 9.0 s late.
You switch a chat UI to a reasoning model and to stream_events(version="v3"). The thinking streams live for half a minute. Then the answer appears in one block, after a pause as long as the answer itself. Your server log shows the model sent the answer token by token. The tokens were in the process all along, in a buffer you did not know you had.
When you finish this section, you can name the function that produces each stream mode and the moment in the superstep when it does. You can also explain issue langchain#38484 from the code, and write a v3 consumer that shows every token when it arrives.
One queue, seven modes, six producers
Every stream mode of stream() writes to one queue. The loop drains it between task completions, and the v2 format wraps each item as a StreamPart with type, ns, and data. We recorded the call stack at the moment each item went onto the queue:
| Mode | Producer | When |
|---|---|---|
checkpoints, debug | _prepare_tasks_and_emit_checkpoint | at the start of the next superstep |
tasks | tick | when the tasks are planned, and again with each result |
updates | put_writes, then output_writes | as each task finishes |
values | after_tick | after the update phase |
messages | StreamMessagesHandler.on_llm_new_token | for each model token, by callback |
custom | the stream_writer closure | when your code calls the writer |
Two rows matter in practice. updates arrives per task, so a slow parallel task does not hold back the update of a fast one. values waits for the whole superstep. One create_agent run with every mode on, with Qwen3 4B on the x86 server guest, shows the order:
1894.5 ms messages AIMessageChunk chunk text='' node=model step=1
1894.6 ms messages AIMessageChunk chunk text='' node=model step=1
1894.6 ms updates keys=['model']
1894.6 ms tasks result model
1894.6 ms debug type=task_result step=1
1895.5 ms values 2 messages
1895.5 ms checkpoints step=1 next=['tools']
1895.5 ms debug type=checkpoint step=1
1895.5 ms tasks start tools
1895.5 ms debug type=task step=2
1899.6 ms custom {'progress': 'looking up Paris'}
1899.6 ms messages ToolMessage chunk text='Paris: sunny' node=tools step=2
…
2658.7 ms messages AIMessageChunk chunk text='The' node=model step=3
2726.1 ms messages AIMessageChunk chunk text=' weather' node=model step=3The first model step took 1.89 s and streamed no text, because its reply was a tool call. The tools step took 4.5 ms. The answer then streamed one token about every 67 ms. These times come from one run on a loaded guest, so read the order of the modes and not the times. Figure 2.7 places each mode on the phases of the run.
The v3 stream is pulled by the reader
stream_events(version="v3") runs no background thread. It runs the graph only when the reader asks for more. A projection such as message.text keeps a list of deltas and a cursor. When the cursor reaches the end of the list, the iterator calls _request_more, which runs the graph until a new event arrives. The iterator stops when the projection is marked done.
Each pulled event goes to every projection of its message. A text delta goes to the list of message.text, even when nobody reads that list yet.
The cause of langchain#38484
Issue langchain#38484 reports that a v3 consumer gets the final answer in one burst. Section 5.1 reproduced it. The code shows why.
All three projections of a message are marked done in one place, when the whole message finishes. The end of the reasoning block finalizes that block, and it does not complete message.reasoning. So this loop cannot leave its first for until the last text token has arrived:
for message in stream.messages:
if pattern == "reasoning_then_text":
for d in message.reasoning:
got.append((now(), "reasoning", d))
for d in message.text:
got.append((now(), "text", d))
elif pattern == "text_only":
for d in message.text:
got.append((now(), "text", d))
elif pattern == "raw_events":
for ev in message:
if ev.get("event") == "content-block-delta":
delta = ev.get("delta", {})
kind = "reasoning" if delta.get("type") == "reasoning-delta" else "text"
got.append((now(), kind, delta.get("reasoning") or delta.get("text")))While the reasoning loop waits, it pulls the text deltas into the list of message.text. When the message ends, the second loop finds all of them there.
We measured the three loops on the x86 server guest with Qwen3 8B, reasoning on, through create_agent, 5 runs per loop, the loops interleaved. The send time is when the Ollama HTTP stream gave LangChain the part. Each run had 211 reasoning deltas and then 60 text deltas: Raw runs
run 0 reasoning_then_text emitted r/t=211/60 received r/t=211/60 text emit [31688.1, 40330.7] spread 8642.6 ms; text receive [40474.7, 40474.8] spread 0.1 ms; text lag median/max [4635.1, 8786.6]; reasoning lag median/max [0.7, 7.0]
run 0 text_only emitted r/t=211/60 received r/t=0/60 text emit [32307.5, 41001.4] spread 8693.9 ms; text receive [32308.2, 41002.2] spread 8694.0 ms; text lag median/max [0.7, 4.6]; reasoning lag median/max None
run 0 raw_events emitted r/t=211/60 received r/t=211/60 text emit [32819.0, 42027.1] spread 9208.1 ms; text receive [32819.8, 42027.8] spread 9208.0 ms; text lag median/max [0.7, 0.9]; reasoning lag median/max [0.7, 4.0]In 5 of 5 runs, the loop that read reasoning first got all 60 text deltas within 0.1 ms of each other. The model had sent them over 8.6 to 8.9 s. This is one run on a loaded guest, so read it as an order. The Mac rows in section 5.1 give the lag as 4.0 to 8.5 s.
Its reasoning deltas arrived live. The text-only loop got the text with a median lag of 0.7 ms and a maximum of 4.9 ms over 300 deltas. The raw loop got them with a median of 0.7 ms and a maximum of 0.9 ms. Figure 2.8 puts run 0 of each loop on one axis.
A closed pull request for the issue, #38533, passed the run config to model_.invoke in create_agent. That change does not touch this mechanism. In the same agent, the text-only and raw loops already got every delta live, so the model callbacks reach the stream without it.
The consumer to write
Pick one of two shapes. When you show only the answer, read message.text alone. When you show reasoning and answer, read the raw events of each message and switch on the delta type, as the raw_events branch above does. Each delta then reaches your UI in the order the model sent it.
Do not read two projections of one message one after the other. The rule holds for message.tool_calls too, which section 5.1 measured. A projection that you read second always waits for the end of the message.
LangChain (Python): langchain, langchain-core, langgraph, deepagents, langsmith 1.5.0 · c2f4036 · 2026-11-11 · Edition 2026.11