Integration
Memory for LangGraph agents
LangGraph keeps each thread's state with a checkpointer, and a store holds data across threads. This page shows how to add Harny memory to a LangGraph agent.
What the framework does not keep
- Which value is current. LangGraph keeps the state your graph writes. Harny stores a changed value with its timestamp, so the newer value becomes the current one and the earlier value stays answerable by date.
- When a fact happened. A checkpoint records when a step ran, not when the fact in the conversation happened. Harny takes a timestamp for each memory, so you can ask what was true on a given date.
- One person across sessions. Harny gives each person who uses your app a private memory that your agent can read. You name the person with your own id, so the same person's memory is there in every thread.
The pattern: memory as a tool
Your LangGraph agent gets plain Python functions as its tools. Each function calls the Harny Memory API with the signed-in user's id, so the model reads and writes only that person's memory.
Your code binds the signed-in user to each tool call, so the model never chooses whose memory it reads. The app key stays on your server, and each request names the person through the X-Harny-User header.
# model: the chat model you already use in LangGraph
import os
import requests
BASE = "https://api.harny.ai/v1/memory"
def make_memory_tools(user_id: str):
headers = {
"Authorization": f"Bearer {os.environ['HARNY_APP_KEY']}",
"X-Harny-User": user_id, # set by your application, never by the model
}
def recall_memory(question: str) -> str:
"""Look up what is known about this user that is relevant to a question."""
r = requests.post(f"{BASE}/recall", headers=headers,
json={"query": question, "identity": user_id})
return r.text
def store_memory(text: str, happened_at: str) -> str:
"""Save a fact with the ISO time it happened."""
r = requests.post(f"{BASE}/ingest", headers=headers,
json={"content": text, "timestamp": happened_at})
return r.text
return [recall_memory, store_memory]
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(model, tools=make_memory_tools(user_id))
result = agent.invoke({"messages": [("user", "What is the Acme pilot budget?")]})What recall returns
Ranked memory with dated sources and source labels. Every result names the data point (source) behind it and the date it happened.
POST https://api.harny.ai/v1/memory/ingesttakesid,content,labelandtimestamp.POST https://api.harny.ai/v1/memory/recalltakesqueryandidentity, and returns results withsources.
Example: your agent asks “what is the Acme pilot budget?” and gets this back. Your code hands the model the content and the source label, so it can say who said it and when.
{
"asOf": "2026-07-29T00:00:00Z",
"results": [
{
"rank": 1,
"occurredAt": "2026-07-28T16:00:00Z",
"content": "Acme pilot budget: currently 40k.",
"sources": [
{ "sourceId": "call-8821", "label": "Email from Nadia" }
]
}
]
}When to use which
- Use LangGraph's own state and checkpointer for the working state of a graph run, such as the steps and messages of the current thread.
- Add Harny when a fact has to survive across threads and sessions, change over time, or be read back as it was on a given date.
Frequently asked questions
Is a package needed?
The page's code calls the Memory API over HTTP from your server. The Python SDK, installed with pip install harny, is a separate option for the agent loop and is not required for memory calls.
Where does the user id come from?
Your app supplies it. Use the id you already have for the signed-in person, and send it in the X-Harny-User header with your app key, which starts with fsa_. A user key, which starts with fsk_, names its own user and needs no header.
Keep reading
Go on. Get Harny.
The first 500 monthly-active end users are free for good. Create an app key and make your first call in minutes.