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
  • 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
OverviewGetting startedinjectStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsDependency injectionType safetyMigrating to v1
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/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

Class

MediaAssemblyError

Typed error thrown through media.stream / rejected from

Class

StreamService

@Injectable() wrapper around useStream. Extend this class

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

Function

handleHeadlessToolInterrupt

Function

headlessToolResumeCommand

Function

injectAudio

Subscribe to a scoped audio-media stream. Each handle is yielded

Function

injectChannel

Function

injectChannelEffect

Side-effect counterpart to injectChannel. Instead of

Function

injectExtension

Subscribe to a custom:<name> stream extension — the most recent

Function

injectFiles

Subscribe to a scoped file-media stream. Pair with

Function

injectImages

Subscribe to a scoped image-media stream. Pair with

Function

injectMediaUrl

Resolve the lazy MediaBase.objectURL promise into a string

Function

injectMessageMetadata

Read metadata recorded for a specific message id — today exposes

Function

injectMessages

Subscribe to a scoped messages stream.

Function

injectProjection

Angular-side primitive that composes ChannelRegistry.acquire

Function

injectStream

Angular entry point for the v2-native stream runtime.

Function

injectSubmissionQueue

Function

injectToolCalls

Subscribe to a scoped tools (tool-call) stream. Same target and

Function

injectValues

Subscribe to a scoped values stream — the most recent state

Function

injectVideo

Subscribe to a scoped video-media stream. Pair with

Function

isHeadlessToolInterrupt

Function

parseHeadlessToolInterruptPayload

Parses a headless-tool interrupt value from the graph. Accepts both

Function

provideStream

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

Function

provideStreamDefaults

Provides default LangGraph configuration at the application level.

Function

useStream

Framework-free factory that constructs a StreamController

Interfaces

Types

Interface

AgentServerAdapter

Public v1 name for TransportAdapter plus optional high-level

Interface

AssembledToolCall

Reactive tool handle for framework bindings (stream.toolCalls,

Interface

AudioMedia

Shared surface across every media handle returned by

Interface

FileMedia

Shared surface across every media handle returned by

Interface

FlushPendingHeadlessToolInterruptsOptions

Interface

HeadlessToolImplementation

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

Interface

HeadlessToolInterrupt

Represents a headless tool interrupt payload emitted by LangChain's

Interface

HttpAgentServerAdapterOptions

Interface

ImageMedia

Shared surface across every media handle returned by

Interface

InjectChannelEffectOptions

Options for injectChannelEffect. Extends the projection

Interface

InjectSubmissionQueueReturn

Reactive handle on the server-side submission queue.

Interface

MediaBase

Shared surface across every media handle returned by

Interface

MessageMetadata

Metadata tracked per message id. Surfaced to applications via

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.

Interface

SubgraphDiscoverySnapshot

Lightweight discovery record for a subgraph running inside the thread.

Interface

SubmissionQueueEntry

Queued submission entry mirrored from the server-side run queue.

Interface

ThreadStream

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

Interface

ToolEvent

Interface

UseStreamReturn

Return shape of useStream — the Angular StreamApi.

Interface

VideoMedia

Shared surface across every media handle returned by

Type

AgentServerOptions

Type

AnyHeadlessToolImplementation

Type

AnyMediaHandle

Type

AnyStream

Erased handle useful as a parameter type for helper components that

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,

Type

InferSubagentStates

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

Type

InferToolCalls

Infer the discriminated union of AssembledToolCall handles

Type

MediaAssemblyErrorKind

Kinds of failure that can terminate a media handle prematurely.

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:

Type

StreamApi

Convenience alias — the fully-resolved return type of

Type

SubmissionQueueSnapshot

Read-only snapshot of the queue. The queue store hands this out

Type

ToolCallFromTool

Infer the streaming AssembledToolCall handle for a single

Type

ToolCallsFromTools

Infer a union of tool call types from an array of tools.

Type

ToolCallState

The lifecycle state of a tool call.

Type

ToolCallStatus

High-level outcome of a single tool call.

Type

UseStreamOptions

Type

UseStreamResult

React-compatible alias for the fully-resolved stream handle type.

Type

WidenUpdateMessages

Widen an update type so its messages field also accepts