Overview
LangChainβs streaming system lets you surface live feedback from agent runs to your application. Whatβs possible with LangChain streaming:- Stream agent progress β get state updates after each agent step.
- Stream LLM tokens β stream language model tokens as theyβre generated.
- Stream custom updates β emit user-defined signals (e.g.,
"Fetched 10/100 records"). - Stream multiple modes β choose from
updates(agent progress),messages(LLM tokens + metadata), orcustom(arbitrary user data).
Agent progress
To stream agent progress, use thestream method with streamMode: "updates". This emits an event after every agent step.
For example, if you have an agent that calls a tool once, you should see the following updates:
- LLM node:
AIMessagewith tool call requests - Tool node:
ToolMessagewith execution result - LLM node: Final AI response
LLM tokens
To stream tokens as they are produced by the LLM, usestreamMode: "messages":
Custom updates
To stream updates from tools as they are executed, you can use thewriter parameter from the configuration.
Output
If you add the
writer parameter to your tool, you wonβt be able to invoke the tool outside of a LangGraph execution context without providing a writer function.Stream multiple modes
You can specify multiple streaming modes by passing streamMode as an array:streamMode: ["updates", "messages", "custom"]: