or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

execution-runtime.mdfunctional-api.mdgraph-construction.mdhuman-loop-control.mdindex.mdpersistence-checkpoints.mdprebuilt-agents.mdremote-advanced.mdstate-channels.md
tile.json

tessl/npm-langchain--langgraph

A low-level orchestration framework for building controllable AI agents with customizable workflows, long-term memory, and human-in-the-loop capabilities

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@langchain/langgraph@0.4.x

To install, run

npx @tessl/cli install tessl/npm-langchain--langgraph@0.4.0

index.mddocs/

LangGraph

LangGraph is a low-level orchestration framework for building controllable AI agents using a message-passing graph computation model. It provides reliable, persistent workflows with first-class streaming support, human-in-the-loop capabilities, and multi-agent system architecture for production-scale applications.

Package Information

  • Package Name: @langchain/langgraph
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @langchain/langgraph

Core Imports

import { StateGraph, Annotation, START, END } from "@langchain/langgraph";
import { MemorySaver } from "@langchain/langgraph-checkpoint";

For web environments:

import { StateGraph, Annotation, START, END } from "@langchain/langgraph/web";

For CommonJS:

const { StateGraph, Annotation, START, END } = require("@langchain/langgraph");

Basic Usage

import { StateGraph, Annotation, START, END } from "@langchain/langgraph";
import { MemorySaver } from "@langchain/langgraph-checkpoint";

// Define state structure
const GraphAnnotation = Annotation.Root({
  messages: Annotation<string[]>({
    reducer: (x: string[], y: string[]) => x.concat(y),
    default: () => [],
  }),
});

// Define nodes
async function nodeA(state: typeof GraphAnnotation.State) {
  return { messages: [`Node A processed: ${state.messages.length} messages`] };
}

async function nodeB(state: typeof GraphAnnotation.State) {
  return { messages: [`Node B processed: ${state.messages.length} messages`] };
}

// Build and compile graph
const graph = new StateGraph(GraphAnnotation)
  .addNode("nodeA", nodeA)
  .addNode("nodeB", nodeB)
  .addEdge(START, "nodeA")
  .addEdge("nodeA", "nodeB")
  .addEdge("nodeB", END)
  .compile({
    checkpointer: new MemorySaver(), // Enable persistence
  });

// Execute graph
const result = await graph.invoke(
  { messages: ["Hello"] },
  { configurable: { thread_id: "1" } }
);
console.log(result.messages);

Architecture

LangGraph is built on several key architectural layers:

  • Channels: Low-level communication primitives for passing data between nodes
  • Checkpointers: Persistence layer for state snapshots and time-travel debugging
  • Pregel: Core execution engine based on Google's Pregel graph processing model
  • Graph APIs: High-level interfaces (StateGraph, MessageGraph) for building workflows
  • Prebuilt Components: Ready-to-use agents and tools for common patterns

Capabilities

Graph Construction

Core graph building functionality for creating stateful workflows with typed state management and node orchestration.

class StateGraph<SD extends StateDefinition> {
  constructor(stateSchema: SD);
  addNode(key: string, action: NodeType<SD>): StateGraph<SD>;
  addEdge(start: string, end: string): StateGraph<SD>;
  addConditionalEdges(
    source: string,
    path: (state: StateType<SD>) => string | string[],
    pathMap?: Record<string, string>
  ): StateGraph<SD>;
  compile(options?: PregelOptions): CompiledStateGraph;
}

class Annotation {
  static Root<T extends StateDefinition>(fields: T): AnnotationRoot<T>;
}

Graph Construction

State Management & Channels

Channel system for managing state communication and synchronization between graph nodes with various storage patterns.

class BaseChannel {
  update(values: any[]): any;
  get(): any;
  checkpoint(): any;
}

type LastValue<T> = T; // Channel storing most recent value
type Topic<T> = T[]; // Channel storing message history
type DynamicBarrierValue = any; // Dynamic synchronization barrier

State Management & Channels

Execution & Runtime

Core execution engine providing streaming execution, runtime configuration, and graph processing capabilities.

class Pregel<Nodes, Channels, ContextType, InputType, OutputType> {
  invoke(
    input: InputType,
    config?: LangGraphRunnableConfig
  ): Promise<OutputType>;
  stream(
    input: InputType,
    config?: LangGraphRunnableConfig
  ): AsyncIterableIterator<OutputType>;
  streamMode: "values" | "updates" | "messages" | "checkpoints" | "debug";
}

Execution & Runtime

Persistence & Checkpoints

State persistence system enabling checkpoint-based recovery, state history, and time-travel debugging for long-running workflows.

class BaseCheckpointSaver {
  put(
    config: RunnableConfig,
    checkpoint: Checkpoint,
    metadata: CheckpointMetadata,
    newVersions: ChannelVersions
  ): Promise<RunnableConfig>;
  getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined>;
  list(
    config: RunnableConfig,
    options?: CheckpointListOptions
  ): AsyncGenerator<CheckpointTuple>;
}

class MemorySaver extends BaseCheckpointSaver {
  constructor();
}

Persistence & Checkpoints

Prebuilt Agents & Components

Ready-to-use agent implementations and tool integration for common AI agent patterns like ReAct, function calling, and tool execution.

function createReactAgent(params: CreateReactAgentParams): CompiledStateGraph;
function createAgentExecutor(config: AgentExecutorConfig): CompiledStateGraph;

class ToolNode {
  constructor(tools: ToolType[], options?: ToolNodeOptions);
}

Prebuilt Agents & Components

Human-in-the-Loop & Control Flow

Interactive workflow capabilities with interruption points, approval flows, and dynamic control flow for human oversight.

function interrupt<I, R>(value: I): R;
function isInterrupted<Value>(values: unknown): values is Interrupt<Value>;

class Command<Resume, Update, Nodes> {
  resume: Resume;
  update: Update;
  goto: Nodes;
}

class Send<Node, Args> {
  node: Node;
  args: Args;
}

Human-in-the-Loop & Control Flow

Functional API & Tasks

Task-based programming interface providing functional composition patterns and declarative workflow definition.

function task<ArgsT, OutputT>(
  optionsOrName: TaskOptions | string,
  func: TaskFunc<ArgsT, OutputT>
): (...args: ArgsT) => Promise<OutputT>;

function entrypoint<InputT, OutputT>(
  optionsOrName: EntrypointOptions | string,
  func: EntrypointFunc<InputT, OutputT>
): Pregel<...>;

Functional API & Tasks

Remote Execution & Advanced Features

Distributed graph execution, schema integration, and advanced streaming capabilities for complex multi-system workflows.

class RemoteGraph {
  constructor(params: RemoteGraphParams);
  invoke(input: any, config?: LangGraphRunnableConfig): Promise<any>;
}

function getStateTypeSchema(graph: unknown): JSONSchema | undefined;
function getUpdateTypeSchema(graph: unknown): JSONSchema | undefined;

Remote Execution & Advanced Features

Error Handling

class BaseLangGraphError extends Error {
  name: string;
  message: string;
}

class GraphInterrupt extends BaseLangGraphError {
  constructor(value?: any);
}

class GraphRecursionError extends BaseLangGraphError {}
class GraphValueError extends BaseLangGraphError {}
class NodeInterrupt extends GraphInterrupt {}

Common Constants

const START: "__start__"; // Graph entry point
const END: "__end__"; // Graph termination
const INTERRUPT: "__interrupt__"; // Interruption marker