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/langgraphwebNativeStreamTransformer
Interface●Since v0.3

NativeStreamTransformer

Copy
interface NativeStreamTransformer

Bases

StreamTransformer<TProjection>

Properties

Methods

Inherited fromStreamTransformer

Methods

Mfail
—

Mark the channel as failed after all buffered items are consumed.

Mfinalize→ void | PromiseLike<void>
—

Called once when the underlying Pregel run completes without throwing.

Minit→ TProjection
—

Called once before the run starts.

View source on GitHub
M
onRegister
—

Optional hook invoked by StreamMux.addTransformer immediately

Mprocess→ boolean
—

Called for each ProtocolEvent before it is appended to the main log.

property
__native: true
method
fail
method
finalize→ void | PromiseLike<void>
method
init→ TProjection
method
onRegister
method
process→ boolean

Marker interface for transformers provided by internal LangChain products (e.g. ReactAgent's ToolCallTransformer, DeepAgent's SubagentTransformer).

Native transformers differ from user-defined extension transformers in where their projection lands on the run stream:

  • Native — projections become direct getters on a GraphRunStream subclass (e.g. run.toolCalls, run.subagents). They emit events on protocol-defined channels (tools, lifecycle, tasks, etc.).

  • Extension (user-defined) — projections are merged into run.extensions. Events emitted via emit() use an application-chosen method name (e.g. emit("a2a", data)) and are accessible to remote clients via session.subscribe("custom:<name>").

The __native brand is used by downstream stream factory functions to distinguish native transformers from extension transformers at registration time. See docs/native-stream-transformers.md for the full pattern.

Mark the channel as failed after all buffered items are consumed.

Called once when the underlying Pregel run completes without throwing. Optional — only needed for non-channel teardown (e.g. resolving promises).

May return a PromiseLike<void> to defer the main event log close until the async work (e.g. emitting terminal lifecycle events) has completed. The mux awaits all returned promises before closing its event log.

Called once before the run starts.

Optional hook invoked by StreamMux.addTransformer immediately after the transformer is attached to the mux. Receives a limited handle that exposes only StreamEmitter.push — enough for the transformer to emit synthesized ProtocolEvents on any namespace it chooses (e.g. a deepagents SubagentTransformer fabricating lifecycle/messages/values events under a ["tools:<tool_call_id>"] namespace when a task tool starts).

Transformers that do not synthesize events can omit this hook.

The StreamEmitter handle is only safe to call from within StreamTransformer.process. Emitting from an unrelated async context (e.g. after process has returned, from a setTimeout, etc.) races with the mux's close/fail cycle and may land events in an already-closed log.

Called for each ProtocolEvent before it is appended to the main log.