Integration
Memory for Agno agents
This page shows how to add Harny memory to an Agno agent so each signed-in person has their own memory the agent can read. Agno agents can call the functions you give them as tools. Harny gives each person who uses your app a private memory that your server reads and writes through the Memory API.
What the framework does not keep
- Which value is current. Harny keeps dated memories. 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 date.
- One person across sources. Each person's memory is separate in Harny, and recall returns each result with its sources.
The pattern: memory as a tool
Plain functions in the tools list become tools the agent can call. You can write functions that call the Harny Memory API from your server to read and write memory, so the agent works with memory as it works with any other tool.
Take the user id from your own sign-in and send it in the X-Harny-User header, so the id does not depend on the model's output.
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 agno.agent import Agent
agent = Agent(
model=model, # the model you already use in Agno
tools=make_memory_tools(user_id),
instructions="Call recall_memory before you answer a question about a customer.",
)
agent.print_response("What is the Acme pilot budget?")What recall returns
Memory results with sources. Each result carries its sources, with a source id, the date it happened and a label.
POST https://api.harny.ai/v1/memory/ingesttakesid,content,labelandtimestamp. It answers 202 with aningestionId.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 Agno's own session state for the conversation in progress, such as the messages and tool results of the current run.
- 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 separate package needed?
The Memory API is plain HTTP with your app key. Authenticate each request with your app key from a server, never from a browser.
Where does the user id come from?
Use your own id for the person, sent in the X-Harny-User header with the app key. Bind it from your sign-in code so the agent reads and writes only that person's memory.
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.