How to Add Memory to a Vercel Eve Agent with Redis
In a session, an Eve agent remembers everything that happened. But if the user opens a session tomorrow again, the agent has empty context. If the user said "I'm vegetarian", the agent doesn't remember this.
That’s why we’ve built the Upstash AgentKit Eve extension. This single file extension grants your Eve agent access to long-term memory with semantic search and searchable chat history capabilities. Upstash Redis handles the embeddings, eliminating the need to manage any embedding model, vector database, or external memory service.
What you get:
- Semantic search. A recall for "dinner food preferences location" finds "The user is vegetarian." and "The user lives in Lisbon." even though they share no words. Recall matches by meaning and by keyword.
- Facts saved for you. The model stores lasting facts with a save tool as the user mentions them, so you write no extraction code.
- Automatic recall. With the AgentKit memory slot, the facts that match the new message go into the prompt before every turn. With the extension, the model gets a recall tool.
- Memory per user. Every fact and chat is keyed by the caller that Eve's auth verified.
- One file. The extension mounts from
agent/extensions/and adds its own short instructions to the system prompt. - Searchable chat history. Past sessions are saved as they stream, and the model can search and read them.
(See also other memory providers listed by Eve, which offer different tradeoffs.)
What memory does an Eve agent need?
Eve agents need conversational history as well as long-term memory about the user. While long-term memory is short facts about the user that the Eve agent loads into every new conversation, chat history is what was said in those conversations. These types of data need to persist across sessions, so we store them in Redis and not in Eve's session store.
The two kinds behave differently:
| Chat history | Long-term memory | |
|---|---|---|
| Scope | One Eve session | One user, across all sessions |
| What gets stored | Every user and assistant message, in order | Short facts ("The user is vegetarian.") |
| Who writes it | An extension hook, as each message streams | The model, through a tool call |
| How it's read | The model searches past chats with a tool, and your app lists them for a sidebar | The model calls a recall tool, which searches by keyword and meaning |
Eve prunes its own workflow store at the end of runs, so the long-term record needs to live somewhere else. Redis is good for both roles because it's fast enough to read from every turn, and you can keep the transcripts and the memories (as well as the search index on top of them) in one database.
Set up the project
Start from a new Eve project and add the AgentKit extension. The @upstash/agentkit-sdk package is only for reading chats from your own app code later:
npx eve@latest init my-agent --non-interactive
cd my-agent
npm install @upstash/agentkit-eve-extension @upstash/agentkit-sdk @upstash/redisCreate a Redis database in the Upstash Console and set its REST URL and token in the agent's environment, next to your model key:
UPSTASH_REDIS_REST_URL="https://..."
UPSTASH_REDIS_REST_TOKEN="..."
ANTHROPIC_API_KEY="..."We call Anthropic directly with Eve's built-in model helper, so no AI Gateway setup is needed:
// agent/agent.ts
import { defineAgent } from "eve";
import { anthropic } from "eve/models/anthropic";
export default defineAgent({
model: anthropic("claude-haiku-5-5"),
});Store chat history
The extension is one file under agent/extensions/. Turning on chat history adds a hook that saves every user and assistant message to Redis as the session streams:
// agent/extensions/agentkit.ts
import agentkit from "@upstash/agentkit-eve-extension";
export default agentkit({ chatHistory: true });The filename provides the tool prefix so the model gets the following tools:
agentkit__save_memoryagentkit__recall_memoryagentkit__search_chat_historyagentkit__read_chat_history
The extension injects a short section into the system prompt instructing the model on when to use them.
The extension keys every memory and chat by the caller that Eve's channel auth verified. Under eve dev, the localDev() authenticator that eve init sets up accepts local requests as one stand-in local-dev caller, so there is nothing to configure while you build. In production, the caller comes from the auth you put in agent/channels/eve.ts: vercelOidc() on Vercel, or a small function that maps your app's signed-in user to an Eve caller. The Eve auth guide covers both. The caller ID is the only thing separating one user's data from another's, and it always comes from verified auth, never from what the client sends.
Each session is one JSON document at agentkit:chat:<userId>:<sessionId>. Your app reads the same store with ChatHistory, for example to build a sidebar of past chats:
import { Redis } from "@upstash/redis";
import { ChatHistory } from "@upstash/agentkit-sdk";
type StoredMessage = { role: "user" | "assistant"; content: string; createdAt: number };
const history = new ChatHistory<StoredMessage>({ redis: Redis.fromEnv() });
const userId = "local-dev"; // the caller id the agent saw; in production, your signed-in user id
const chats = await history.listChats({ userId, limit: 50 });
for (const c of chats) console.log(c.sessionId, c.messageCount, JSON.stringify(c.title));
const chat = await history.getChat({ userId, sessionId: chats[0].sessionId });
chat?.messages.forEach((m) => console.log(`${m.role}: ${m.content.slice(0, 80)}`));After the two conversations in the next section, it printed:
wrun_01M7N72D96G57R43174881YBXZ 2 "Suggest a dinner place for me tonight."
wrun_01M7N726K4ZW15NCRTHEYH093F 2 "I'm vegetarian and I live in Lisbon."
user: Suggest a dinner place for me tonight.
assistant: Since you're vegetarian and in Lisbon, try **Refúgio** (Rua da Escola PolitécnicNote these do not help with session resumption (which Eve does with its own session ID) but the extension uses the title of the chat from the first user message. These tools are used for getting existing chats.
Give the agent long-term memory
The memory tools need no extra config. agentkit__save_memory stores one fact about the user, and agentkit__recall_memory searches for the facts that match a query. The agent's instructions stay as eve init wrote them plus one line on style, with nothing about memory:
<!-- agent/instructions.md -->
You are a helpful assistant. Keep answers short.We started the agent with npx eve dev --no-ui and ran two separate sessions with Eve's client SDK. Both come from the same local-dev caller, so they share one user's memory. The first one shares two facts, and the second one asks a question that needs them:
import { Client } from "eve/client";
// `eve dev` accepts local requests as the `local-dev` caller, so no token is needed.
const client = new Client({ baseUrl: "http://127.0.0.1:2000" });
async function ask(message: string) {
const { delivery } = await client.sessions.create({ message });
for await (const event of delivery.stream()) {
if (event.type === "call.requested") {
console.log(`tool: ${event.data.capability.name} ${JSON.stringify(event.data.input)}`);
}
}
const { reply } = await delivery.result();
console.log(`> ${message}\n${reply}\n`);
}
await ask("I'm vegetarian and I live in Lisbon.");
await ask("Suggest a dinner place for me tonight.");New memories take a few seconds to become searchable, so we ran the second session once the first session's facts showed up in the index, 12.8 seconds later. The output:
tool: agentkit__save_memory {"text":"The user is vegetarian."}
tool: agentkit__save_memory {"text":"The user lives in Lisbon."}
> I'm vegetarian and I live in Lisbon.
Thanks, I've noted that you're vegetarian and live in Lisbon. I'll keep both in mind for food, restaurant, and local recommendations.
tool: agentkit__recall_memory {"query":"dinner food preferences location"}
> Suggest a dinner place for me tonight.
For tonight in Lisbon, try **Prato Verde**, a well-known vegetarian restaurant in the city centre. It's worth checking today's opening hours and booking ahead...Redis stores these memories as JSON documents at agentkit:memory:<userId>:<id>, here agentkit:memory:local-dev:<id>. You can see them in the Upstash Console Data Browser.
In the second session, we didn't say anything about the diet and the city. But the agent knew it from Redis.
How recall finds the right memories
agentkit__recall_memory uses Upstash Redis Search to query the memories in multiple ways (keyword and similarity search), then combines the rankings. When you store the memories in Upstash Redis, it converts them into embeddings. This means the extension only sends the text, no extra calls to an embedding model.
In the second session, the model looks for memories about the query dinner food preferences location. Notice how none of the words in the query match "The user is vegetarian." or "The user lives in Lisbon.". Yet, the memory can find them because it uses similarity search.
Hybrid search ranks results instead of filtering them, so a recall returns up to topK memories for any query. Setting memory: { minScore } in the mount switches recall to keyword matches above that BM25 score, if you would rather get fewer, exact hits. Called with no query, agentkit__recall_memory returns every memory for the user.
Redis Search indexes new documents in the background. In our runs, new memories became searchable 4 to 13 seconds after the first session, and the newest chat showed up in listChats after about 8 seconds. When we ran the second session right away, its recall came back empty and the agent asked for the user's city. Right after the extension creates its index on a new database, the first documents can take up to about a minute. That's fine across conversations, but a fact saved in one turn may not turn up in a search on the very next turn.
Eve memory providers vs the AgentKit extension
Eve has some memory slots, stored in a file in agent/memory/. Eve calls it before and after each turn, with the data stored by a provider (the docs list its built-in file memory, Supermemory, Upstash AgentKit, and Kybernesis Arcana, a memory service with semantic search).
They differ from the extension in where data lives and how recall works:
| AgentKit extension | Eve file memory | AgentKit memory slot | |
|---|---|---|---|
| Ships as | @upstash/agentkit-eve-extension | Built into Eve | @upstash/agentkit-eve |
| Where data lives | Your Upstash Redis | Vercel Blob on Vercel, in-process memory under eve dev | Your Upstash Redis |
| How memories are recalled | The model calls a recall tool (keyword and meaning) | The whole document is added before every turn | Keyword and meaning search on the user's message, added before every turn |
| How memories are saved | The model calls a save tool | The model calls a save tool | User messages saved after each turn, plus a save tool |
| Chat history | Searchable transcripts per session | None | A tool replays a past session |
| Recall limit | topK memories per search | 4,000 characters by default, 64 KB per document | 5 memories and 4,000 characters by default |
We also ran the two-conversation demo with the AgentKit memory slot, redisMemory() from @upstash/agentkit-eve/memory, in place of the extension, again with no memory instructions:
// agent/memory/recall.ts
import { redisMemory } from "@upstash/agentkit-eve/memory";
import { defineMemory } from "eve/memory";
import { byPrincipal } from "eve/memory/scope";
export default defineMemory({
description: "Stable facts and preferences about the caller.",
provider: redisMemory(),
scope: byPrincipal,
});Before the second conversation's first turn, the slot searched memory with "Suggest a dinner place for me tonight." and added this to the prompt, with no tool call:
# Recalled memories for recall
...
ef137db78fe1: The user is vegetarian. (session=wrun_01M7N74SMJKH4CXZ8J2VCG2D8P)
131402304bd2: The user lives in Lisbon. (session=wrun_01M7N74SMJKH4CXZ8J2VCG2D8P)The agent answered with vegetarian places in Lisbon. The slot also saves each user message after the turn, so facts the model never saved can still be recalled later.
AgentKit also includes a redisDocuments() backend for the file memory provider, which replays an entire short document to the model on each turn, so it never misses a fact because of wording. File memory uses a Vercel Blob store in deployment, and does not include chat history. Supermemory automatically records turns, recalls memories with semantic search before each turn, and uses its own service to store memory instead of the user’s database.
Which one to use
For most Eve agents, the extension covers both types of memory with one file: chatHistory: true keeps searchable transcripts, and the memory tools save facts and find them again by meaning. With default settings, chat history and memory share one search index, so the extension works on a free Upstash Redis database, which allows one index. If you'd rather have memories added to the prompt before every turn than wait for the model to call a tool, use the memory slot. A full example app that uses the extension can be found in the AgentKit repo, and the full range of options are described in the AgentKit Eve docs.
If you’re looking to add RAG with your own documents in an Eve agent, check out our guide on how we built Ask HackerNews with Eve.
The AgentKit extension is a good solution if you want to allow full control of the memory and chat history data in a way that’s easily viewable, manipulable, and deletable. No black boxes here, it’s just JSON documents stored at well-known keys. Use it if you’d like to use the same Redis database for rate limits, RAG, and more, as well as if you need the ability to list and search past conversations in your app with ChatHistory.
Use Eve’s file memory if you only need a small list of facts per user, and are already deploying on Vercel with Blob.
Use Supermemory if you want a hosted service to decide which facts are relevant, with the memories stored in its service instead of your database.