LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphstream
Module●Since v0.3

stream

Copy
import { ... } from "@langchain/langgraph/stream";

Functions

function
inferChannel→ Channel | undefined
function
isPrefixMatch→ boolean
function
isStreamChannel→ value is EventLog<unknown>
function
isSupportedChannel→ value is Channel
function
matchesSubscription→ boolean
function
normalizeNamespaceSegment→ string
function
convertToProtocolEvent→ ProtocolEvent[]
function
isCheckpointEnvelope→ boolean

Classes

class
EventLog
class
StreamChannel

Interfaces

Type Aliases

Variables

View source on GitHub
interface
MatchableEvent

Minimal protocol-event shape consumed by inferChannel and matchesSubscription.

Both the core ProtocolEvent and the wire-level Event from @langchain/protocol structurally satisfy this contract, so the same predicates can drive in-process fan-out, buffered replay, and server-side (SSE / WebSocket) event-sink filtering without coupling to a single event type.

interface
ConvertToProtocolEventOptions
interface
ProtocolEvent

Single envelope for a streaming protocol emission: sequence, channel (method), and payload (params).

typeAlias
ProtocolMethod: StreamMode | "lifecycle" | "input" | string & __type

Channels that can appear on a protocol event. Beyond the raw StreamMode channels emitted by the Pregel stream, the v2 protocol layer synthesizes additional channels (e.g. lifecycle, input) via built-in StreamTransformers and exposes user-defined channels created with StreamChannel.

typeAlias
Namespace: string[]

Hierarchical path identifying a position in the agent tree.

Each element is one segment; longer arrays mean deeper nesting (e.g. subgraph or multi-agent scopes).

variable
SUPPORTED_CHANNELS: Set<Channel>

The base protocol subscription channels, excluding the templated custom:<name> form. This is the runtime counterpart to the Channel union from @langchain/protocol and mirrors the channel set a server recognizes when filtering its event sinks.

variable
STREAM_EVENTS_V3_MODES: StreamMode[]

The set of stream modes requested by streamEvents(..., { version: "v3" }) — every mode the protocol maps to a channel.

The verbose "debug" mode is intentionally excluded: it was a thin re-wrap of checkpoints + tasks carrying no new information.

The "checkpoints" mode is likewise excluded from the stream-mode request because the protocol's checkpoints channel carries only a lightweight envelope (id, parent_id, step, source) emitted as a separate [namespace, "checkpoints", envelope] chunk before each paired values chunk — not the full-state shape from Pregel's checkpoints stream mode when subscribed via debug.

Maps a protocol event method to its subscription Channel.

Returns undefined for unrecognized methods so that new server-side channels (e.g. from extension transformers) don't break existing subscribers. The custom method resolves to the named custom:<name> channel when the payload carries a name, otherwise the bare custom channel. Both "input" and the wire-level "input.requested" map to the input channel.

Whether namespace starts with prefix.

Segments are compared literally first; if the prefix segment itself contains no :, the candidate segment is also compared after its dynamic suffix is stripped (see normalizeNamespaceSegment). This mirrors is_prefix_match in api/langgraph_api/protocol/namespace.py so server-side filtering and client-side per-subscription narrowing stay consistent.

@langchain/langgraph/stream — backend toolkit for the v2 streaming protocol.

This entrypoint collects the primitives needed to build a custom transport or server on top of the Agent Streaming Protocol:

  • StreamChannel — an append-only, buffered event log with independent replay cursors, for buffering events and fanning them out to multiple subscribers.
  • convertToProtocolEvent — turns raw streamEvents (v3) payloads into canonical ProtocolEvents.
  • inferChannel / matchesSubscription — map an event to its Channel and decide whether a buffered event should be delivered for a given subscription filter (with optional since replay cursor).
  • SUPPORTED_CHANNELS / isSupportedChannel — the recognized channel set and a guard for validating subscription requests.

These are intentionally transport-agnostic: pair them with SSE, WebSocket, or any custom framing to expose a graph over the protocol.

Whether value names a protocol subscription channel — either a base channel ("messages", "values", …) or a named custom channel ("custom:<name>"). Unknown/future method names return false, mirroring inferChannel.

Returns whether an event should be delivered for a subscription definition.

When the definition carries a since replay cursor, events at or before that sequence number are excluded — letting the same predicate drive both live fan-out and buffered replay over a StreamChannel.

Strip dynamic suffixes (after :) from a namespace segment.

Server-emitted namespaces contain runtime-generated suffixes like "fetcher:abc-uuid", while user-supplied subscription filters are typically static names ("fetcher"). Mirrors normalize_namespace_segment in api/langgraph_api/protocol/namespace.py.

True when payload is a lightweight checkpoint envelope (not a full-state Pregel checkpoints debug payload).

A projection channel for StreamTransformers.

Implements AsyncIterable<T> so it can be iterated directly by in-process consumers via run.extensions.<key>. Channels created with StreamChannel.remote or new StreamChannel(name) are also auto-forwarded to remote clients.

A projection channel for StreamTransformers.

Implements AsyncIterable<T> so it can be iterated directly by in-process consumers via run.extensions.<key>. Channels created with StreamChannel.remote or new StreamChannel(name) are also auto-forwarded to remote clients.