LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraphstreamrun_streamGraphRunStreaminterleave
    Methodā—Since v1.1

    interleave

    Copy
    interleave(
        self,
        *names: str = (),
    ) -> Iterator[tuple[str
    View source on GitHub
    ,
    Any
    ]
    ]

    Parameters

    NameTypeDescription
    *namesstr
    Default:()

    Iterate multiple projections round-robin, yielding (name, item).

    Each turn advances one projection's cursor; when a cursor's buffer is empty, pulling from it drives the pump once, which fans out to every subscribed projection log. Projections whose items aren't consumed on this turn sit in their own buffers only until the next turn reaches them, bounding memory by the skew between projection rates rather than letting any single log grow to the full run length.

    Projections are exhausted independently; a projection that finishes early drops out of the rotation while others continue. The overall iterator ends once all named projections are done.

    Example:

    for name, item in run.interleave("messages", "values"):
        if name == "messages":
            print("msg:", item)
        else:
            print("val:", item)

    Projection keys to interleave. Must match keys in extensions.