interface CompiledGraphWhether to automatically validate the graph structure when it is compiled. Defaults to true.
Optional cache for the graph, useful for caching tasks.
The channels in the graph, mapping channel names to their BaseChannel or ManagedValueSpec instances
Execute multiple operations in a single batch.
Returns a drawable representation of the computation graph.
Returns a drawable representation of the computation graph.
Gets the current state of the graph.
Gets the history of graph states.
Gets all subgraphs within this graph.
Gets all subgraphs within this graph asynchronously.
Run the graph with a single input and config.
Create a new runnable sequence that runs each individual runnable in series,
Streams the execution of the graph, emitting state updates as they occur.
Updates the state of the graph with new values.
Validates the graph structure to ensure it is well-formed.
Creates a new instance of the Pregel graph with updated configuration.
// Using StateGraph API
const graph = new StateGraph(annotation)
.addNode("nodeA", myNodeFunction)
.addEdge("nodeA", "nodeB")
.compile();
// The compiled graph is a Pregel instance
const result = await graph.invoke(input);// Using Functional API
import { task, entrypoint } from "@langchain/langgraph";
import { MemorySaver } from "@langchain/langgraph-checkpoint";
// Define tasks that can be composed
const addOne = task("add", async (x: number) => x + 1);
// Create a workflow using the entrypoint function
const workflow = entrypoint({
name: "workflow",
checkpointer: new MemorySaver()
}, async (numbers: number[]) => {
// Tasks can be run in parallel
const results = await Promise.all(numbers.map(n => addOne(n)));
return results;
});
// The workflow is a Pregel instance
const result = await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]Whether to automatically validate the graph structure when it is compiled. Defaults to true.
The channels in the graph, mapping channel names to their BaseChannel or ManagedValueSpec instances
Optional checkpointer for persisting graph state. When provided, saves a checkpoint of the graph state at every superstep. When false or undefined, checkpointing is disabled, and the graph will not be able to save or restore state.
The default configuration for graph execution, can be overridden on a per-invocation basis
Whether to enable debug logging. Defaults to false.
Optional array of node names or "all" to interrupt after executing these nodes. Used for implementing human-in-the-loop workflows.
Optional array of node names or "all" to interrupt before executing these nodes. Used for implementing human-in-the-loop workflows.
The name of the task, analogous to the node name in StateGraph.
The nodes in the graph, mapping node names to their PregelNode instances
Optional retry policy for handling failures in node execution
Optional timeout in milliseconds for the execution of each superstep
Optional long-term memory store for the graph, allows for persistence & retrieval of data across threads
The streaming modes enabled for this graph. Defaults to ["values"]. Supported modes:
The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model inspired by Google's Pregel system. It provides the foundation for building reliable, controllable agent workflows that can evolve state over time.
Key features:
The Pregel class is not intended to be instantiated directly by consumers. Instead, use the following higher-level APIs:
PregelPregel instance is returned by the entrypoint function