LangChain
langchain-mnemoverse connects LangChain agents and chains to Mnemoverse memory. The memory lives in your Mnemoverse account, so what an agent saves here is also there in Claude, ChatGPT, Cursor, VS Code and the other tools connected to the same account.
MnemoverseRetrieverreturns the memories relevant to a query as LangChainDocumentobjects, for chains and RAG.MnemoverseToolkitgives an agent three tools:mnemoverse_search,mnemoverse_saveandmnemoverse_rate. Rating a recalled memory as helpful or misleading changes what comes back next for similar questions.MnemoverseMiddlewarerecalls the memories relevant to the user's latest message once percreate_agentrun and adds them to the system message, within a time budget. If recall is slow or fails, the run goes on without memory.
Install
pip install "langchain-mnemoverse[agents]"The agents extra brings the langchain package, which only the middleware needs; the retriever and the tools work with pip install langchain-mnemoverse. Create an API key at console.mnemoverse.com and set it as MNEMOVERSE_API_KEY, or pass api_key=.
An agent with memory
from langchain.agents import create_agent
from langchain_mnemoverse import MnemoverseMiddleware, MnemoverseToolkit
agent = create_agent(
model="openai:gpt-4.1-mini", # needs pip install langchain-openai and OPENAI_API_KEY
tools=MnemoverseToolkit(domain="user:ana").get_tools(),
middleware=[MnemoverseMiddleware(domain="user:ana")],
)
agent.invoke({"messages": [{"role": "user", "content": "Remember that I always take the window seat."}]})
result = agent.invoke({"messages": [{"role": "user", "content": "Which seat do I take on flights?"}]})
print(result["messages"][-1].content)The middleware reads once at the start of every run, so a tool loop does not read again. The agent saves only when it calls mnemoverse_save, which its description limits to what the user asks it to remember.
A retriever for chains
from langchain_mnemoverse import MnemoverseRetriever
retriever = MnemoverseRetriever(domain="project:docs", k=4)
for doc in retriever.invoke("Which database does the ledger use?"):
print(doc.id, doc.metadata["relevance"], doc.page_content)Each document's id is the memory's id; ainvoke works the same way.
One domain per user
Every call reads and writes one domain, such as user:ana. In an app with several users, leave domain out of the tools and the middleware and name it per run, from your app's signed-in user on the server:
agent.invoke(
{"messages": [{"role": "user", "content": "Which seat do I take?"}]},
config={"configurable": {"mnemoverse_domain": f"user:{user_id}"}},
)The model can never set the domain. A run with no domain gets no memory, and a run that names two different domains, in its config and its context, is refused rather than reading one user's memory and writing another's. The retriever takes domain= per call. A domain separates how memory is used, not who may read it: the API key reads every domain of its account, so give each app its own key (what one key shares).
Limits and cost
Each retriever call and each tool call is one API call, and the middleware makes at most one read per agent run. Reads, writes and ratings count together against your plan's daily query limit (pricing). Queries are cut to their last 5,000 characters and the save tool refuses a memory over 10,000 characters, before any request. Settings, error handling and every option are in the package README.
Tested
Version 0.1.0 is tested with fake SDK clients, including LangChain's standard retriever and tool test suites, with mnemoverse 0.5.2 and langchain-core 1.8.4 on Python 3.11 to 3.14, and with the lowest supported versions on Python 3.11. Its live test suite against the API runs on demand and was not part of the release.
Related
langchain-mnemoverseon GitHub: settings, errors, compatibility- Agent frameworks: LangGraph, CrewAI and n8n, and LangChain without the package
- Python SDK
- Agent memory: when to recall and what to save