WOLBΛRG

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:

  1. WolbargMemory@langchain/core BaseMemory (legacy chain memory: recall on load, remember on save)
  2. WolbargStore — LangGraph BaseStore (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/langgraph

Peers: 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

OptionDefaultNotes
memoryrequiredWolbarg instance
agentrequiredAgent id for recall/remember filters
memoryKey"history"Key returned from loadMemoryVariables
inputKey / outputKeyautoPassed to LangChain getInputValue / getOutputValue
topK5Recall limit
returnMessagesfalseReturn HumanMessage[] instead of a string
formatContextdefault formatterCustom string formatter for hits
rememberMode"raw"Passed to rememberFromMessages
sessionId / userId / tags / namespace / metadataCopied onto stored metadata
onErrorSoft-fail hook

WolbargStore / createWolbargStore

MethodWolbarg mapping
putremember (text from value.text / value.data / JSON.stringify)
getmetadata key lookup (+ process cache)
deleteforget by memory id
search (+ query)recall
batchabstract 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 get after 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 onError for observability.