CortexDB Docs
Integrations

LangGraph

Persist LangGraph agent state and long-term memory in CortexDB.

CortexDB backs LangGraph both as a checkpointer (durable graph state) and as a recall source for long-term memory across runs.

Install

pip install cortexdbai[langgraph]

Checkpointer

from cortexdb import Cortex
from cortexdb.integrations.langgraph import CortexDBCheckpointer

client = Cortex(api_url="https://api-v1.cortexdb.ai", actor="user:alice",
                bearer=os.environ["CORTEX_TOKEN"])

checkpointer = CortexDBCheckpointer(client=client, scope="org:acme/user:alice")
graph = builder.compile(checkpointer=checkpointer)

Recall inside a node

Use the SDK directly in any node to pull long-term context:

def retrieve_node(state):
    pack = client.recall(scope="org:acme/user:alice", view="holistic",
                         query=state["input"], include=["events", "facts", "episodes"],
                         budgets={"max_tokens": 3000}, diagnostics="none")
    return {"context": pack.get("context_block", "")}

context_block may be empty

On a fresh scope (or a content-only self-host where derived layers are empty) context_block can be empty — check for it before injecting. Use wait="indexed" on the capture in the same turn if you need read-after-write. See Self-hosting defaults.

See also

On this page