LangChain & LangGraph

Long-term memory for LangChain and LangGraph agents

Add one middleware to create_agent: each turn recalls what this user said before, in any thread, or tells the model there is no record.

pip install langchain-recallic

Python
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")
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)
# another thread, days later
agent.invoke({"messages": [{"role": "user", "content": "Which city do I live in now?"}]}, config=alice)
  • RecallicMiddleware recalls on the user's latest message before the model answers and keeps your own system prompt.
  • When nothing answers, the model is told there is no record instead of being handed near-misses.
  • RecallicRetriever for chains and your own LangGraph nodes; recallic_tools() when the agent should decide itself.
  • Each user's memory is separate: user_id is fixed, or read per run from the context or config.

Settings

user_id
Default
None
What it does
fixed user; None reads user_id from the run's context or configurable
mode
Default
server's
What it does
cautious, balanced or helpful
limit
Default
5
What it does
memories given to the model per turn

Needs a running Recallic server: set one up with Docker, or deploy it to your own Render account in one click. Nothing goes through us; your data stays on your server.