SDKUpdated 2026-03-18
LangGraph Adapter
Store LangGraph checkpoint state in RetainDB so stateful agents can resume by thread.
Applies to: @retaindb/sdk
The LangGraph adapter is for teams already using LangGraph's checkpointer pattern for agent state.
Installation
bash
npm install @retaindb/sdkUsage
typescript
import { RetainDBClient, createLangGraphCheckpointAdapter } from "@retaindb/sdk";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatOpenAI } from "@langchain/openai";
const client = RetainDBClient.fromEnv(); // reads RETAINDB_API_KEY
const checkpointer = createLangGraphCheckpointAdapter(client, {
userIdPrefix: "langgraph-thread",
defaultCheckpointNs: "default",
});
const agent = createReactAgent({
llm: new ChatOpenAI({ temperature: 0 }),
tools,
checkpointer,
});
const config = { configurable: { thread_id: "conversation-1" } };
await agent.invoke({ messages: ["Hi"] }, config);
await agent.invoke({ messages: ["What did I say?"] }, config);Adapter options
| Option | Type | Default | Description |
|---|---|---|---|
userIdPrefix | string | "langgraph-thread" | Namespace for checkpoint storage |
defaultCheckpointNs | string | "default" | Default checkpoint namespace |
The adapter derives user_id and session_id internally from the thread config. You do not pass them directly.
Why userIdPrefix exists
Checkpoints are stored as RetainDB memories. userIdPrefix namespaces those writes so LangGraph state doesn't mix with your application's user memories.
Next step
Was this page helpful?
Your feedback helps us prioritize docs improvements weekly.