Skip to content

LangGraph (TypeScript)

TypeScript port of LangGraph. Same graph-based mental model as the Python version — explicit state, durable checkpoints, conditional routing — with type-safe streaming, ReducedValue/UntrackedValue types, and the @langgraphjs/toolkit prebuilt agent package.

Install

Terminal window
npm install @langchain/langgraph

Version

v1.3.0 · May 2026 · Node 18+

Best for

Cycles, conditional routing, multi-agent coordination, streaming servers.

  • MessagesZodState / MessagesZodMeta — Zod-based companion to MessagesAnnotation. Use MessagesZodState when you want full Zod type inference on your messages state instead of the Annotation-based API.
  • STREAM_EVENTS_V3_MODES — constant listing all valid v3 streaming modes ("values", "updates", "messages", "tools", "custom", "tasks"). Use this to validate or enumerate mode strings at runtime.
  • createGraphRunStream / GraphRunStream / SubgraphRunStream — new lower-level functional streaming API. Complements the existing .stream() method on compiled graphs with explicit stream lifecycle control.
  • Stream transformerscreateLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer for composing stream pipelines.
  • Schema utilitiesisSerializableSchema, isStandardSchema type guards; getJsonSchemaFromSchema, getSchemaDefaultGetter for schema-to-JSON-Schema conversion.
  • pushMessage — convenience helper for appending a message to a messages-state channel.
  • All 1.2.x features retained: standard JSON Schema (Zod 4, Valibot, ArkType), ReducedValue/UntrackedValue types, @langgraphjs/toolkit.
import { StateGraph, START, END, MemorySaver } from '@langchain/langgraph';
import { BaseMessage } from '@langchain/core/messages';
type State = { messages: BaseMessage[] };
const graph = new StateGraph<State>({ channels: { messages: { reducer: (a, b) => [...a, ...b] } } })
.addNode('respond', async (state) => ({ messages: [/* ... */] }))
.addEdge(START, 'respond')
.addEdge('respond', END)
.compile({ checkpointer: new MemorySaver() });
const result = await graph.invoke(
{ messages: [] },
{ configurable: { thread_id: 'session-1' } }
);
console.log(result);

Ready? Start Zero → Hero Step 1 →


DateVersionChanges
2026-05-051.3.0Version bumped 1.2.9 → 1.3.0; “What’s new” updated for 1.3.0 (MessagesZodState/Meta, STREAM_EVENTS_V3_MODES, createGraphRunStream, stream transformers, schema utilities, pushMessage). All new symbols verified against installed @langchain/langgraph@1.3.0 (.routine-envs/check-0505-node). Comprehensive guide header and revision history updated.
2026-04-211.2.9Index redesigned with Zero → Hero + Jump-to-topic grid.
April 19, 20261.2.9Standard JSON Schema; new type utilities; toolkit package.
November 20251.0.2Initial TypeScript guide.

Note: Python implementation lives at LangGraph (Python).