LangGraph Runtime (Pregel)

Status: ACTIVE (pulled from docs.langchain.com) Source: https://docs.langchain.com/oss/python/langgraph/pregel Timestamp: 2026-05-11

Pregel implements LangGraph's runtime. Compiling a StateGraph or creating an @entrypoint produces a Pregel instance.

Named after Google's Pregel algorithm for large-scale parallel graph computation.

Overview

Pregel combines actors (PregelNodes) and channels into a single application. Actors read from channels and write to channels.

Execution Cycle (Bulk Synchronous Parallel)

Each step has three phases: 1. Plan: Determine which actors to execute 2. Execution: Execute all selected actors in parallel 3. Update: Update channels with actor outputs

Repeats until no actors are selected or max steps reached.

Channels

Communication mechanism between actors.

LastValue (Default)

Stores the last value written, overwriting previous:

from langgraph.channels import LastValue
channel: LastValue[int] = LastValue(int)

Topic

Configurable PubSub for multiple values:

from langgraph.channels import Topic
channel: Topic[str] = Topic(str, accumulate=True)

BinaryOperatorAggregate

Persistent value updated by binary operator:

import operator
from langgraph.channels import BinaryOperatorAggregate

total = BinaryOperatorAggregate(int, operator.add)

DeltaChannel (beta, langgraph>=1.2)

Stores only incremental deltas, not full accumulated value. Reduces checkpoint sizes for channels that grow large over time (e.g., long conversation lists).

from langgraph.channels import DeltaChannel

class State(TypedDict):
    messages: Annotated[list[str], DeltaChannel(my_reducer)]

Bulk reducer (not pairwise): receives current state and sequence of all writes from the step at once. Must be associative.

Use snapshot_frequency to bound read latency: every K steps, a full snapshot is written.

Pregel vs StateGraph/@entrypoint

Most users interact with Pregel through StateGraph or @entrypoint. Direct Pregel usage is for advanced cases:

from langgraph.channels import EphemeralValue
from langgraph.pregel import Pregel, NodeBuilder

node1 = (NodeBuilder()
    .subscribe_only("a")
    .do(lambda x: x + x)
    .write_to("b"))

app = Pregel(
    nodes={"node1": node1},
    channels={
        "a": EphemeralValue(str),
        "b": EphemeralValue(str),
    },
    input_channels=["a"],
    output_channels=["b"],
)
app.invoke({"a": "foo"})
# {'b': 'foofoo'}