LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
  • Overview
  • Getting started
  • injectStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Dependency injection
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
OverviewGetting startedinjectStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsDependency injectionType safetyMigrating to v1
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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/angular

@langchain/angular

Description

@langchain/angular

Angular SDK for building AI-powered applications with Deep Agents, LangChain and LangGraph.

The package ships a Signals-first API built on top of the v2 streaming protocol. injectStream returns a small, always-on root handle (values, messages, isLoading, error, …) and pushes anything namespaced (subagents, subgraphs, media, submission queue, per-message metadata) behind ref-counted inject* selectors so components only pay for data they actually consume.

Upgrading from 0.x? See docs/v1-migration.md for the complete matrix of option, return-shape, and transport changes.

Installation

npm install @langchain/angular @langchain/core

Peer dependencies: @angular/core (^18.0.0 – ^21.0.0), @langchain/core (^1.1.27).

Quick start

import { Component } from "@angular/core";
import { injectStream } from "@langchain/angular";

@Component({
  standalone: true,
  template: `
    <div>
      @for (msg of stream.messages(); track msg.id ?? $index) {
        <div>{{ str(msg.content) }}</div>
      }

      <button
        [disabled]="stream.isLoading()"
        (click)="onSubmit()"
      >
        Send
      </button>
    </div>
  `,
})
export class ChatComponent {
  readonly stream = injectStream({
    assistantId: "agent",
    apiUrl: "http://localhost:2024",
  });

  str(v: unknown) {
    return typeof v === "string" ? v : JSON.stringify(v);
  }

  onSubmit() {
    void this.stream.submit({
      messages: [{ type: "human", content: "Hello!" }],
    });
  }
}

injectStream must be called from an Angular injection context — the host's DestroyRef owns the stream, so navigating away destroys the controller automatically.

Features at a glance

  • Signals everywhere. Messages, values, tool calls, interrupts, loading/error state — all Angular Signal<T>s you call as functions in templates.
  • One call, two transports. Same option bag targets either the LangGraph Platform (SSE by default, transport: "websocket" opt-in) or a custom backend through an AgentServerAdapter.
  • Ref-counted selectors. injectMessages, injectValues, injectToolCalls, media selectors, submission queue — the first consumer opens a subscription, the last one's DestroyRef closes it. Components pay only for what they render.
  • Human-in-the-loop. Interrupts are first-class signals; resume or fork a specific pending interrupt with one call.
  • Headless tools. Register browser-side tool implementations; the runtime dispatches matching interrupts and auto-resumes with the return value.
  • Subagent & subgraph discovery. Lightweight snapshots at the root; scoped content (messages, tool calls, state) via the same selectors, targeted at a snapshot or namespace.
  • Forking without history preload. Per-message metadata + submit({ forkFrom }) replaces the legacy branch / fetchStateHistory trio.
  • DI-native. provideStream for subtree sharing, provideStreamDefaults for app-wide config, StreamService for class-based wrappers.
  • Typed end-to-end. Pass typeof agent as the first generic — state, tool args, and per-subagent state flow through to every selector.

Public stream types

Use StreamApi<T> when you need to name the return type of injectStream, useStream, provideStream, or StreamService in Angular code. It is the Angular-facing alias for the Signals-first handle.

UseStreamResult<T> is also exported as a React-compatible alias for the same shape. Prefer it only in shared utilities that are designed to accept stream handles from multiple framework packages.

Documentation

In-depth guides live under docs/:

  • inject-stream.md — options + return-shape reference
  • transports.md — SSE, WebSocket, and custom AgentServerAdapter
  • custom-transport.md — implementing AgentServerAdapter against your own backend, with a worked walkthrough of examples/ui-react-transport
  • selectors.md — scoped reads (injectMessages, injectValues, media, channels, …)
  • interrupts.md — handling and responding to interrupts
  • branching.md — forking via injectMessageMetadata + submit({ forkFrom })
  • submission-queue.md — injectSubmissionQueue and multitaskStrategy: "enqueue"
  • headless-tools.md — browser-side tool implementations
  • subagents-subgraphs.md — discovery snapshots and scoped content
  • dependency-injection.md — provideStream, provideStreamDefaults, StreamService
  • type-safety.md — generics, agent inference, and public stream aliases
  • testing.md — STREAM_INSTANCE fakes and service overrides
  • v1-migration.md — migrating from 0.x

Playground

For complete end-to-end examples, visit the LangChain UI Playground.

License

MIT

Classes

Class

HttpAgentServerAdapter

Public v1 name for TransportAdapter plus optional high-level capabilities. Renamed to reflect that this interface now denotes the full agent-server protocol contract (not merely wire transport): any o

Class

MediaAssemblyError

Typed error thrown through media.stream / rejected from media.blob / media.objectURL when a handle fails before its message completes. Carries the bytes accumulated up to the failure point on `p

Class

StreamService

@Injectable() wrapper around useStream. Extend this class with your own service when you want a DI-scoped, shareable StreamApi:

@Injectable({ providedIn: "root" })
export class ChatStream ext

Functions

Function

executeHeadlessTool

Function

filterOutHeadlessToolInterrupts

Strip headless-tool interrupts from a user-facing interrupt list.

Function

findHeadlessTool

Function

flushPendingHeadlessToolInterrupts

Execute and resume all newly seen headless-tool interrupts from a values payload. Callers own handledIds and should clear it when the thread changes.

Function

handleHeadlessToolInterrupt

Function

headlessToolResumeCommand

Function

injectAudio

Subscribe to a scoped audio-media stream. Each handle is yielded on its first matching content-block-start, exposes .partialBytes for live access, settles .blob / .objectURL / .transcript on

Function

injectChannel

Function

injectChannelEffect

Side-effect counterpart to injectChannel. Instead of returning a signal of buffered events, it invokes onEvent once per event for as long as the owning component / service is alive — the idiomatic p

Function

injectExtension

Subscribe to a custom:<name> stream extension — the most recent payload emitted by the transformer, scoped to the target namespace.

Returns only the latest value and resumes across serial runs, so

Function

injectFiles

Subscribe to a scoped file-media stream. Pair with injectMediaUrl for an <a download href> target.

Function

injectImages

Subscribe to a scoped image-media stream. Pair with injectMediaUrl for <img src>.

Function

injectMediaUrl

Resolve the lazy MediaBase.objectURL promise into a string suitable for direct use in <audio src> / <img src> / <video src> / <a href download>. Returns undefined until the URL is available.

Function

injectMessageMetadata

Read metadata recorded for a specific message id — today exposes parentCheckpointId, the checkpoint the message was first seen on. Designed for fork / edit flows:

readonly meta = injectMessag
Function

injectMessages

Subscribe to a scoped messages stream.

Contract:

  • At the root (no target) this returns stream.messages — the always-on root projection; no extra subscription is opened.
  • For any non-root
Function

injectProjection

Angular-side primitive that composes ChannelRegistry.acquire with Angular Signals + DestroyRef.

Contract (mirrors the React useProjection hook and the Vue useProjection composable, but adapted to

Function

injectStream

Angular entry point for the v2-native stream runtime.

Call from a component, directive, or service field initializer to attach an StreamApi bound to the current DestroyRef:

@Component({ templa
Function

injectSubmissionQueue

Function

injectToolCalls

Subscribe to a scoped tools (tool-call) stream. Same target and lifecycle rules as injectMessages; at the root this returns stream.toolCalls directly.

Function

injectValues

Subscribe to a scoped values stream — the most recent state payload for a namespace. At the root returns stream.values.

Typing:

  • Root (injectValues(stream)): returns the StateType de
Function

injectVideo

Subscribe to a scoped video-media stream. Pair with injectMediaUrl for <video src>.

Function

isHeadlessToolInterrupt

Function

parseHeadlessToolInterruptPayload

Parses a headless-tool interrupt value from the graph. Accepts both toolCall (LangChain JS) and tool_call (Python / JSON snake_case).

Function

provideStream

Creates a provider for a shared useStream instance at the component level.

Add the returned provider to a component's providers array so that all child components can access the same stream via `

Function

provideStreamDefaults

Provides default LangGraph configuration at the application level.

Use this in your application's providers array to set defaults like apiUrl that will be used by all useStream and `injectStrea

Function

useStream

Framework-free factory that constructs a StreamController and wraps its stores in Angular Signals. Callers must supply the DestroyRef that owns the controller's lifetime — it's already captured by the

Interfaces

Types

Interface

AgentServerAdapter

Public v1 name for TransportAdapter plus optional high-level capabilities. Renamed to reflect that this interface now denotes the full agent-server protocol contract (not merely wire transport): any o

Interface

AssembledToolCall

Reactive tool handle for framework bindings (stream.toolCalls, useToolCalls, injectToolCalls).

status, error, and output are plain values that the assembler updates in place as tool events arri

Interface

AudioMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

FileMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

FlushPendingHeadlessToolInterruptsOptions

Interface

HeadlessToolImplementation

Client-side implementation returned by headlessTool.implement(...).

Interface

HeadlessToolInterrupt

Represents a headless tool interrupt payload emitted by LangChain's schema-only tool({ ... }) overload.

Servers may serialize the nested tool call as toolCall (JS) or tool_call (Python). Use pa

Interface

HttpAgentServerAdapterOptions

Interface

ImageMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

InjectChannelEffectOptions

Options for injectChannelEffect. Extends the projection options (bufferSize, replay) with the per-event callback, an optional error sink, a target scope, and an enabled gate.

Interface

InjectSubmissionQueueReturn

Reactive handle on the server-side submission queue.

Populated when submit() is invoked with multitaskStrategy: "enqueue" while another run is in flight. The returned entries signal is stable p

Interface

MediaBase

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

MessageMetadata

Metadata tracked per message id. Surfaced to applications via useMessageMetadata(stream, messageId).

Interface

StreamDefaults

Configuration defaults for useStream and injectStream calls.

Interface

StreamStopOptions

Options for StreamController.stop / framework stop().

Interface

StreamSubmitOptions

Interface

SubagentDiscoverySnapshot

Lightweight discovery record for a subagent running inside the thread.

Populated eagerly from the root subscription (tools + lifecycle channels). Content projections (messages, toolCalls, cus

Interface

SubgraphDiscoverySnapshot

Lightweight discovery record for a subgraph running inside the thread.

Interface

SubmissionQueueEntry

A single queued submission.

Interface

ThreadStream

High-level wrapper around a protocol connection to a specific thread.

In the thread-centric protocol, threads are durable (backed by checkpoints) and connections are ephemeral. A ThreadStream is th

Interface

ToolEvent

Interface

UseStreamReturn

Return shape of useStream — the Angular StreamApi.

Reactivity primitives follow Angular conventions:

  • Data projections are Signal<T>; call them as functions in templates (`stream.messages()
Interface

VideoMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Type

AgentServerOptions

Type

AnyHeadlessToolImplementation

Type

AnyMediaHandle

Type

AnyStream

Erased handle useful as a parameter type for helper components that pass a stream through to selector primitives without reading values directly. Mirrors the React/Vue AnyStream alias.

Widening

Type

CustomAdapterOptions

Type

DefaultToolCall

Default tool call type when no specific tool definitions are provided.

Type

InferStateType

Unwrap the state shape from a compiled graph, a create-agent brand, or a plain type. Used by useStream<T>() to resolve T = typeof agent into the state the values/messages projections observe.

Type

InferSubagentStates

Infer the subagent → state map from a DeepAgent brand. Non-brands collapse to DefaultSubagentStates.

Type

InferToolCalls

Infer the discriminated union of AssembledToolCall handles from an agent brand, an array of LangChain tools, or fall back to the untyped default handle.

Pass typeof agent or typeof tools and narr

Type

MediaAssemblyErrorKind

Kinds of failure that can terminate a media handle prematurely.

  • "message-error" — the upstream message emitted an error event before completion.
  • "stream-closed" — the transport stream clo
Type

MediaBlockType

Block types this assembler knows how to reassemble into media handles.

Type

MessageMetadataMap

Read-only map exposed via MessageMetadataTracker.store.

Type

OnToolCallback

Type

SelectorTarget

What a selector primitive can be targeted at. Callers can pass:

  • undefined / null — root namespace (served by the always-on root store — no extra subscription);
  • a SubagentDiscoverySnapshot
Type

StreamApi

Convenience alias — the fully-resolved return type of useStream for a given source type T.

Type

SubmissionQueueSnapshot

Read-only snapshot of the queue. The queue store hands this out directly; consumers must not mutate the array.

Type

ToolCallFromTool

Infer the streaming AssembledToolCall handle for a single LangChain tool.

Parallel to ToolCallFromTool for message-level tool calls — use this when a component receives one entry from `stream.toolCal

Type

ToolCallsFromTools

Infer a union of tool call types from an array of tools. Works with tools created via tool() from @langchain/core/tools.

Type

ToolCallState

The lifecycle state of a tool call.

  • pending: Tool call received, awaiting result
  • completed: Tool execution finished successfully
  • error: Tool execution failed (result.status === "error")
Type

ToolCallStatus

High-level outcome of a single tool call.

Type

UseStreamOptions

Type

UseStreamResult

React-compatible alias for the fully-resolved stream handle type. Angular docs prefer StreamApi, but shared libraries can use this name across framework bindings.

Type

WidenUpdateMessages

Widen an update type so its messages field also accepts @langchain/core BaseMessage class instances (single or array). Framework bindings apply this to submit() so callers can write `stream.subm