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
    LangGraph Store
    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
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    PythonlanggraphgraphstateStateGraphcompile
    Method●Since v0.1

    compile

    Copy
    compile(
      self,
      checkpointer: Checkpointer = None,
      *,
      cache: BaseCache | None
    View source on GitHub
    =
    None
    ,
    store
    :
    BaseStore
    |
    None
    =
    None
    ,
    interrupt_before
    :
    All
    |
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    interrupt_after
    :
    All
    |
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    debug
    :
    bool
    =
    False
    ,
    name
    :
    str
    |
    None
    =
    None
    ,
    transformers
    :
    Sequence
    [
    Callable
    [
    [
    tuple
    [
    str
    ,
    .
    .
    .
    ]
    ]
    ,
    Any
    ]
    ]
    |
    None
    =
    None
    )
    ->
    CompiledStateGraph
    [
    StateT
    ,
    ContextT
    ,
    InputT
    ,
    OutputT
    ]

    Parameters

    NameTypeDescription
    checkpointerCheckpointer
    Default:None

    A checkpoint saver object or flag.

    If provided, this Checkpointer serves as a fully versioned "short-term memory" for the graph, allowing it to be paused, resumed, and replayed from any point.

    If None, it may inherit the parent graph's checkpointer when used as a subgraph.

    If False, it will not use or inherit any checkpointer.

    Important: When a checkpointer is enabled, you should pass a thread_id in the config when invoking the graph:

    config = {"configurable": {"thread_id": "my-thread"}}
    graph.invoke(inputs, config)

    The thread_id is the key used to store and retrieve checkpoints. Use a unique ID for independent runs, or reuse the same ID to accumulate state across invocations (e.g., for conversation memory).

    interrupt_beforeAll | list[str] | None
    Default:None

    An optional list of node names to interrupt before.

    interrupt_afterAll | list[str] | None
    Default:None
    debugbool
    Default:False
    namestr | None
    Default:None
    transformersSequence[Callable[[tuple[str, ...]], Any]] | None
    Default:None

    Compiles the StateGraph into a CompiledStateGraph object.

    The compiled graph implements the Runnable interface and can be invoked, streamed, batched, and run asynchronously.

    An optional list of node names to interrupt after.

    A flag indicating whether to enable debug mode.

    The name to use for the compiled graph.

    Optional sequence of StreamTransformer classes or configured factories. Classes and factories are instantiated per run whenever stream_events(version="v3") / astream_events(version="v3") is called and are propagated to subgraph scopes. Custom factories should follow the standard StreamTransformer constructor shape by accepting scope as their first argument. Appended after the built-in stream transformers.