From Token Streams to Agent Streams
Key point
LangChain unveiled a new architecture that goes beyond token streaming to stream messages, tool calls, and sub-agents as structured events
Details
Modern AI agents go beyond simple text generation to perform complex tasks such as planning, delegating to sub-agents, calling tools, waiting for approval, and producing multimodal output. Existing token streaming APIs cannot handle questions like which events occurred at which step once an agent scales into a graph structure, how to subscribe to only a specific sub-agent, or how to reconnect after a browser refresh.
LangChain and LangGraph announced a new streaming architecture centered on typed events instead of raw chunks to address this. The core concepts are as follows.
Channels and namespaces: Events are classified by a channel representing the concern (messages, values, tools, lifecycle, custom:*) and a namespace representing the position within the agent tree. Root graphs, nested subgraphs, and Deep Agents sub-agents can all emit the same channel types while retaining their identity.
Projections: Instead of iterating over raw protocol events, applications directly request the view they want to render. Through run.messages, run.subagents, run.extensions["toolActivity"], and more, they receive text, reasoning, tool call arguments, and usage data as structured content blocks.
Scoped subscriptions: The frontend streams only the part of the agent tree it renders. A sub-agent inspector opens streams only for the sub-agents shown on screen, and a dashboard can display a status list without downloading tokens for every sub-agent.
const thread = client.threads.stream({
assistantId: "research-agent",
});
await thread.subscribe({
channels: ["messages", "tools", "values", "lifecycle"],
namespaces: [["researcher"]],
depth: 2,
});
Framework SDKs: The same streaming model works across local and remote execution, and across the React, Vue, Svelte, Angular SDKs. Each framework expresses the same concepts (root hooks, projections, component-level selectors) in its own idiom (React hooks, Vue composables, Angular injectors).
Multimodal support: The content-block-based design naturally accommodates text, images, audio, and video within the same architecture. In the cookbook's storybook demo, each page scopes a media selector to its responsible graph node, rendering assets as soon as they arrive.
Custom channels: Applications can add domain-specific projections—such as citations, progress events, structured plans, UI descriptions, and workflow metrics—via streaming transformers. Examples include a generative UI pattern where an agent emits declarative A2UI messages over a custom:a2ui channel and a React app subscribes to them to render a real-time interface.
Multiple projections of the same run can be consumed independently, and events include ordering metadata so clients can reconnect and replay from the last point. Runnable Python and TypeScript examples are available in the streaming cookbook.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.