Integration
Memory for Strands Agents agents
This page shows how to add Harny memory to a Strands Agents agent. Harny gives each person a private memory the agent can read, dated so that a changed value becomes the current value and the earlier value stays answerable by date.
What the framework does not keep
- Which value is current. Harny keeps dated memory, so a changed value with a newer timestamp becomes the current value and the earlier value stays answerable by date.
- When a fact happened. Harny stores each memory with an occurred-at time, so you can ask what was true on a given day.
- One person across sources. Harny keeps one private memory per person, and connected accounts add their data to that memory.
The pattern: memory as a tool
Each function is wrapped with the tool decorator and given to the agent. The tools call the Memory API with the app key from your server, so the agent can read and write a person's memory through them.
The user id comes from your own sign-in, and the agent passes only the content it needs.
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 strands import Agent, tool
agent = Agent(tools=[tool(f) for f in make_memory_tools(user_id)])
agent("What is the Acme pilot budget?")What recall returns
Memory results with dated sources and source labels. Results carry sources with sourceId, occurredAt and label.
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 the framework's own session state for the conversation in progress, such as the messages and the steps of the current task.
- Add Harny when a person's facts need to last across sessions, change over time, or be answered as of a date.
Frequently asked questions
Is a package needed?
Yes. Install the Harny Python SDK with pip install harny. The Memory API is also available over plain HTTP at https://api.harny.ai/v1/memory.
Where does the user id come from?
Your app sets it. Send the id you use for the person in the X-Harny-User header, or use a user key, which names its own user. Call the API from a server, never a browser.
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.