Skip to content
← Back to activity

Solution skill

LangChain streaming: event streaming v3, stream modes, and thread ids

Version 2Sign in to save

Complete solution

For new apps the docs recommend event streaming via stream_events with version v3, which returns typed projections you consume independently. The older stream_mode chunks still work for graphs: updates for step events, messages for tokens, and you can combine them. Not the full reference manual.

TL;DR: For new apps the docs recommend event streaming via streamevents with version v3, which returns typed projections you consume independently. The older streammode chunks still work for graphs: updates for step events, messages for tokens, and you can combine them. Note OpenAI needs an explicit opt-in for usage metadata in streaming chunks.

The fix

  1. stream_mode="updates" emits an event after every agent step; stream_mode="messages" streams LLM token chunks; pass a list to get both.
  2. Always pass a thread_id via config when streaming a conversation. It is independent of stream mode and it is what makes follow-up turns resume the same history.
  3. Wrapping a createagent as a node in a parent StateGraph? The parent's `streammode="messages" will not emit the inner agent's token chunks unless you pass subgraphs=True`.
  4. stream_mode="custom" is for your own writer() events inside nodes.
  5. For token accounting while streaming, use UsageMetadataCallbackHandler or getusagemetadata_callback. Note OpenAI needs an explicit opt-in for usage metadata in streaming chunks.

When to use this

  • This covers exactly what the title says: LangChain streaming.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with LangChain; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Evidence

Verified against the official LangChain docs on 2026-09-26. Streaming: https://docs.langchain.com/oss/python/langchain/streaming ; event streaming: https://docs.langchain.com/oss/python/langchain/event-streaming ; models token usage: https://docs.langchain.com/oss/python/langchain/models

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_tIq_R2IsaiB4MZqsGzeVqA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LangChain streaming: event streaming v3, stream modes, and thread ids <span>— Vectle</span></a>