LangChain / LangGraph
Official @wolbarg/langchain — WolbargMemory (BaseMemory), WolbargStore (LangGraph BaseStore), and createWolbargTools.
What is it?
@wolbarg/langchain is the official LangChain JS / LangGraph JS adapter for Wolbarg shared memory.
Two integration surfaces:
WolbargMemory—@langchain/coreBaseMemory(legacy chain memory: recall on load, remember on save)WolbargStore— LangGraphBaseStore(preferred long-term memory for multi-agent / durable graphs)
Also: createWolbargTools — agent tools for wolbarg_recall / wolbarg_remember.
Soft-fail by default: recall/remember/store errors never crash the chain or graph. Provenance metadata always includes source: "wolbarg-langchain".
Requires Node ≥ 22.
Install
npm install wolbarg @wolbarg/langchain @langchain/core @langchain/langgraphPeers: wolbarg >= 0.5.3, @langchain/core >= 0.3 || >= 1, @langchain/langgraph >= 0.2 || >= 1.
Quick start — BaseMemory
import { wolbarg, sqlite, openaiEmbedding } from "wolbarg";
import { createWolbargMemory } from "@wolbarg/langchain";
const memory = wolbarg({
organization: "my-app",
storage: sqlite("./memory.db"),
embedding: openaiEmbedding({
apiKey: process.env.OPENAI_API_KEY!,
model: "text-embedding-3-small",
}),
});
await memory.ready();
const chatMemory = createWolbargMemory({
memory,
agent: "assistant",
memoryKey: "history",
sessionId: "chat-1",
});
const vars = await chatMemory.loadMemoryVariables({
input: "What UI theme do I prefer?",
});
// vars.history — formatted string (or BaseMessage[] when returnMessages: true)
await chatMemory.saveContext(
{ input: "I prefer dark mode" },
{ output: "Noted — dark mode it is." },
);Quick start — LangGraph BaseStore
import { createWolbargStore } from "@wolbarg/langchain";
const store = createWolbargStore({
memory,
agent: "assistant",
});
await store.put(["users", "u1"], "prefs", { text: "dark mode" });
const item = await store.get(["users", "u1"], "prefs");
const hits = await store.search(["users"], {
query: "theme preference",
limit: 5,
});Pass store into LangGraph as the long-term memory store (e.g. graph compile / store config). Prefer WolbargStore for new LangGraph apps; use WolbargMemory when you still need classic BaseMemory chains.
Optional tools
import { createWolbargTools } from "@wolbarg/langchain";
const tools = createWolbargTools({ memory, agent: "assistant" });
// [wolbarg_recall, wolbarg_remember]Options
WolbargMemory / createWolbargMemory
| Option | Default | Notes |
|---|---|---|
memory | required | Wolbarg instance |
agent | required | Agent id for recall/remember filters |
memoryKey | "history" | Key returned from loadMemoryVariables |
inputKey / outputKey | auto | Passed to LangChain getInputValue / getOutputValue |
topK | 5 | Recall limit |
returnMessages | false | Return HumanMessage[] instead of a string |
formatContext | default formatter | Custom string formatter for hits |
rememberMode | "raw" | Passed to rememberFromMessages |
sessionId / userId / tags / namespace / metadata | — | Copied onto stored metadata |
onError | — | Soft-fail hook |
WolbargStore / createWolbargStore
| Method | Wolbarg mapping |
|---|---|
put | remember (text from value.text / value.data / JSON.stringify) |
get | metadata key lookup (+ process cache) |
delete | forget by memory id |
search (+ query) | recall |
batch | abstract entry point (put/get/delete/search/listNamespaces) |
Namespaces are stored in Wolbarg metadata (storeNamespace, storeKey, storeValue).
Limitations
- BaseMemory is legacy LCEL/chain memory — LangGraph apps should prefer
WolbargStore. - Exact
getafter restart is best-effort via metadata-filtered recall; process-local cache is authoritative within a run. - Soft-fail means store/memory errors never crash the chain — wire
onErrorfor observability.