Short-term memory holds the information an AI agent needs for the current conversation or task. Long-term memory retains information for future conversations. Your writing agent uses "shorten this paragraph" for today's draft and might save "use concise language in my articles" for future drafts.
Both types can persist. The distinction is their scope: continuing the same task versus carrying useful information into a future task. Your application decides what to retain and when to retrieve it.
Copy link to headingHow do short-term and long-term memory differ?
Copy link to headingShort-term memory supports the current task
When a coding agent investigates a bug, it uses your report, the relevant code, recent test results, and its planned checks to decide what to do next. This working context can span many model calls. If your application saves and reloads this context, the agent can also continue the task after a restart.
The context window limits what a model can consider in one call. If your application stores more conversation history than fits, it must select messages or summarize earlier exchanges before sending them to the model. Saved history is not necessarily part of the model's current input.
Copy link to headingLong-term memory supports future tasks
For a new task, the coding agent might retrieve confirmed project facts: the code uses TypeScript, runs on Node.js, and stores data in Postgres. Those facts guide its work without requiring you to repeat them.
Long-term memory can also retain lessons from completed tasks. The coding agent might record that adding a missing required environment variable resolved a deployment failure. Save the conditions and evidence so the agent can check whether the lesson applies to a later task.
Agent memory is information your application manages. Saving a preference or task record does not change the model's weights. To use that information, the application must either include it in a model call or provide a tool to retrieve it.
Copy link to headingWhat belongs in short-term and long-term memory?
Before saving information, consider whether the agent needs it for the current task, future tasks, or both. Project decisions can stay in the current working context and also become reusable project records.
Copy link to headingSave confirmed facts for future tasks
Asking a writing agent to use a formal tone for one legal notice gives it an instruction for that task. Saying “Use a formal tone for all our legal notices” gives it a preference you can confirm and save for future notices. That preference should not carry over to your team's social posts.
An agent should distinguish confirmed preferences from its own inferences. One edit is not enough to establish a lasting preference. Save the source and confirmation status with the record, and let users inspect and correct it.
Record what happened separately from why you think it happened. “The deployment failed” is an observation; “a missing environment variable caused the failure” is a hypothesis until checked. Save the lesson for future tasks after you verify the cause and the fix.
Copy link to headingKeep temporary details within their scope
One-off instructions, tentative conclusions, and intermediate tool results often belong only to the current task. You can retain their original records for audit without treating them as current facts in future prompts.
Support agents should retrieve a customer's current invoice status to answer billing questions. An overdue invoice in an earlier ticket may explain that interaction, but does not show whether payment is still due.
Record what changeable information applies to and when it was confirmed. Project decisions may remain valid until replaced, whereas service configurations may require a live check. Age alone does not tell you whether a record is still accurate.
Copy link to headingHow do the two types of memory work together?
Consider a research agent comparing databases for your project. Its working context includes your requirements, the sources it reads, and unresolved questions. You choose Postgres and confirm that each customer's documents must remain separate from other customers' data.
Your application saves the conversation under its conversation ID. It also saves the confirmed database choice and customer data isolation requirement under the project ID, with the date and supporting sources.
The recalled facts become short-term working context for the import conversation. Unrelated alternatives from the earlier comparison can stay outside the prompt.
Retrieval-augmented generation (RAG) retrieves records and includes them in a model's input. It can recall saved project decisions or supply reference knowledge from public database documentation.
Copy link to headingDoes each type of memory need different storage?
Choose storage based on who needs access and how long the information must remain available. One database can hold conversation history and reusable facts under different IDs and access rules. Retrieval determines which records the agent uses for a task.
Durable workflow runtimes can preserve supported data across suspensions and resumptions. They do not automatically retain all process memory.
For agents that work with files, Vercel Sandbox provides isolated execution and Vercel Drives provides persistent directories that you can mount in later sandbox environments. Saved notes can serve as memory when the agent has tools to find and read them.
Use a direct lookup when you know the user or project ID and the field you need. When a task needs to find relevant information across a collection, Upstash Search combines full-text and semantic search, while pgvector adds vector similarity search to Postgres.
Copy link to headingHow do you keep agent memory reliable?
Copy link to headingPreserve requirements and sources
To keep a conversation within the context window, you can trim older turns or summarize them. Trimming avoids an extra model call but can drop earlier requirements. Summarization uses fewer tokens than the full history, but it adds a model call and can omit details or introduce errors. OpenAI's session-memory guide compares the approaches.
Keep requirements that govern the task, such as a supported runtime or acceptance criteria, in the context sent to the model. Recent messages may not contain every requirement the agent still needs.
Link summaries to original messages or files so the agent can check omitted details. Keep exact identifiers separately when an error could change an action. In long-document reading tasks, Google DeepMind's ReadAgent uses compressed summaries and looks up passages in the original text when it needs more detail.
Copy link to headingUpdate saved facts and check access
OpenAI's in-house data agent prompts users to save corrections for future questions and lets them edit personal and global memories. It can also query live data when it needs current information.
Record who each reusable fact belongs to, its source, and when it was updated. When a fact changes, update summaries and indexes that use it. Check access permissions before returning a memory to the model.
Copy link to headingTest recall, corrections, and deletion
LongMemEval tests information extraction, reasoning across conversations, time-based reasoning, knowledge updates, and abstention: declining to answer when evidence is missing. Use these areas to evaluate whether an agent uses memory correctly, beyond checking that a record was saved.
Test your application with these cases:
Start a new conversation and confirm that the agent recalls a saved decision.
Correct the decision and confirm that later answers use the updated value.
Ask a question that the saved records cannot answer and check that the agent acknowledges the gap.
Confirm that one user cannot retrieve another user's private memories.
Delete a fact and verify that summaries and indexes no longer return it.
Copy link to headingFrequently asked questions
Copy link to headingCan short-term AI agent memory survive a restart?
Yes, if your application saves the conversation's messages and task state, then reloads them after the restart. This lets the agent continue the same task without relying on the original process's memory.
Copy link to headingIs a larger context window the same as long-term memory?
No. Increasing the context window lets a model consider more input in one call. It does not provide storage, decide which past information to retrieve, or update a remembered fact when circumstances change.
Copy link to headingIs RAG the same as long-term agent memory?
No. Retrieval-augmented generation (RAG) can support long-term memory by retrieving saved preferences or decisions for a response. It can also supply reference knowledge from public documentation.
Copy link to headingDoes saved chat history carry over to new conversations?
Not by itself. Saving chat history preserves a conversation record. To use it in a new conversation, your application must select relevant information, check that the user or project can access it, and provide it to the agent through context or tools.
Copy link to headingCan Vercel Drives store long-term memory for AI agents?
Yes. Vercel Drives can retain notes, project decisions, and task records as files across sandbox environments. Your application gives the agent tools to find and read relevant files and handles memory selection, access, and updates.
Copy link to headingWhen should you save information as long-term memory?
Save information for future conversations when another task is likely to need it, you know which user or project it applies to, and you can verify or correct it. Confirmed preferences, project decisions, and validated task outcomes are useful candidates.