Skip to main content

langchain-recallic: Recallic memory for LangChain and LangGraph

Long-term memory for LangChain and LangGraph agents, backed by a self-hosted Recallic server.

  • No LLM calls for memory. Storing and searching use Recallic's local models.
  • Across threads and sessions. Each turn, what this user said before that bears on their latest message is recalled, whatever thread it was said in.
  • Honest. When nothing answers it, the model is told there is no record instead of being handed near-misses to guess from.
  • Your data stays on your server, separated per user and per agent.

Install

pip install langchain-recallic

Run Recallic (quickstart) and create a key with role service, which acts for each of your users (or use a user's own key and leave user_id out):

python -m backend.tools.keys create --user my-langchain-app --role service

Automatic memory: RecallicMiddleware

For agents built with create_agent (LangChain 1.x; it runs on LangGraph):

import os

from langchain.agents import create_agent
from langchain_recallic import RecallicMiddleware

memory = RecallicMiddleware(os.environ["RECALLIC_SERVICE_KEY"], base_url="http://localhost:8000",
                            mode="balanced")                       # or "cautious" / "helpful"
agent = create_agent("openai:gpt-5-mini", tools=[...], middleware=[memory])

alice = {"configurable": {"user_id": "alice"}}
agent.invoke({"messages": [{"role": "user", "content": "I moved to Pune in March."}]}, config=alice)

# days later, another thread
agent.invoke({"messages": [{"role": "user", "content": "Which city did I move to?"}]}, config=alice)  # "Pune."

Before each model call it recalls on the user's latest message and adds the memories to the system message (your own system prompt is kept), or tells the model there is no record. Then it stores that message. In a tool loop the recall runs once per user message.

Parameter Default What it does
user_id None A fixed user. None reads user_id per run from the run's context (with context_schema) or config["configurable"].
agent_id langchain Recallic agent id; each agent reads back what it wrote (and what any agent shared).
mode server's recall.mode cautious checks every answer twice; helpful answers more counting, ordering and "how long between" questions.
limit 5 Memories given to the model per turn.
store_user_messages True Store the user's latest message each turn (after recalling).
tell_model_on_decline True When nothing answers, tell the model not to guess about the user's past.

Retriever: RecallicRetriever

For chains, RAG pipelines and your own LangGraph nodes:

from langchain_recallic import RecallicRetriever

retriever = RecallicRetriever(api_key=os.environ["RECALLIC_SERVICE_KEY"], user_id="alice", k=5)
docs = retriever.invoke("Where do I work?")    # [] when Recallic has no memory that answers it

Tools: recallic_tools()

When the agent should decide itself when to look things up or save them:

from langchain_recallic import recallic_tools

tools = recallic_tools(os.environ["RECALLIC_SERVICE_KEY"])    # recall_memory(query), save_memory(fact)
agent = create_agent("openai:gpt-5-mini", tools=tools)
agent.invoke({"messages": [...]}, config={"configurable": {"user_id": "alice"}})

Notes:

  • format_memories(recall_result) turns any Recallic recall result into the text the middleware gives the model.
  • Needs Recallic server 0.2.5 or newer. Tested with langchain 1.5 and langgraph 1.2.

Tests

Against a running Recallic: RECALLIC_URL=http://127.0.0.1:8000 RECALLIC_SERVICE_KEY=rx_... pytest tests. They include real create_agent runs with a scripted model.

Licence: Apache-2.0.

Metadata

Release files for langchain-recallic 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-recallic 0.1.0
File Size Uploaded Provenance Actions
langchain_recallic-0.1.0.tar.gz 7.8 kB Without provenance Details for langchain_recallic-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-recallic 0.1.0
File Interpreter ABI Platform Actions
langchain_recallic-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_recallic-0.1.0-py3-none-any.whl

Total release size: 15.1 kB

Release files / langchain_recallic-0.1.0.tar.gz

Download URL langchain_recallic-0.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
473c80752fd5c2dacaa2b75bc423590b93c168d261931d269b29dc9b98382bad
BLAKE2b-256 checksum
How to use checksums
c31aecdbd536c57aeee81b20ad50f402c08cd032033dab3740550b260e869607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / langchain_recallic-0.1.0-py3-none-any.whl

Download URL langchain_recallic-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ea94e840070f053cb06d1415ad9ee656be5d458a091f125cb0ccce1564a64d
BLAKE2b-256 checksum
How to use checksums
0183e295e87dacbfd12c7a1c53ebe8873b30b0e6355373076f4a9ebf652cc58f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for langchain-recallic 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page