Put an expiry on a memory when the fact it holds goes stale on a schedule or when its source changes, such as a price, a plan year or a deadline. Leave it off a memory that stays valid until a newer fact or a changed source replaces it, such as a user's allergy. A long-lived fact should not lose its validity only because it has been stored for a long time. A post on r/AI_Agents carries the title Agent memory should have an expiration date, and the question deserves more than a yes or no.
What does an expiry date do to a memory?
Some systems expire memories through a retention rule that deletes records past a set age. OpenSearch's agentic memory works this way. Its docs label retention experimental and not recommended for production, and it is off by default: an administrator enables it cluster-wide and sets a policy per container, and long-term retention needs strategies configured. The policy deletes long-term memories older than a set number of days, measured from last_updated_time. A background job runs every 24 hours by default, and until it runs, an expired memory can still appear in search.
The age clock is the detail to check. Age runs from last_updated_time, which advances only when content changes: a working memory is added to a session, or a long-term memory is updated. Reading a memory does not advance it, so a memory the agent only retrieves still ages out. Pinning exempts a memory from deletion without resetting its age, so a pinned memory can become eligible as soon as it is unpinned. The age limit therefore protects memories that are still being written to, and it never checks whether an untouched fact is still true. The count limit ignores age: max_count removes the oldest memories first, even when they are newer than the age limit.
Default settings matter as much as the rule. Unless a retention policy is set, OpenSearch's agentic memories accumulate indefinitely, which increases storage use and can lead agents to retrieve outdated memories. Storage and index growth add infrastructure cost. Model context cost is separate: it depends on how much retrieved content enters each request, which is set by the number of hits, how deep the agent reads and the context budget. agent-memory bounds this by design: recall returns a short list of paths and one-line abstracts, and the agent opens each hit only as deep as the task needs. Cost X-ray shows what each part of a Claude Code request costs.
Other systems expire a fact without deleting it. SurrealDB's agent memory closes the fact's validity interval, so it leaves current retrieval but stays in the entity's history. Check which behavior your tool has before you build on it: store a fact, push its date past the limit, and see whether search still returns it.
How long should an agent memory last?
There is no universal number, and the answer comes from how fast each kind of fact goes stale. A time-to-live (TTL) bounds how long a record is kept and says nothing about whether it is still true. Mem0's write-up on forgetting names the failure: a pure TTL eventually drops a fact that was both old and still true. A user's allergy, a child's name and a workspace's billing structure are examples, and none of them should age out on a fixed schedule.
Three questions stay separate for any memory: is the fact still true, does its record take part in current retrieval, and is the record still stored. Decay lowers a fact's retrieval weight and leaves it valid and stored. Soft expiry, as in SurrealDB, closes the record's validity and keeps it in history; that is the system's bookkeeping, not proof the fact has become false in the world. Retention rules, and any hard delete, remove the record instead. Match the mechanism to the question you have.
A TTL does have a job. Mem0 names legally constrained data as the case where TTL earns its place, because the retention window is set by policy. If a privacy policy promises eighteen months of retention, a TTL keeps that promise. Outside a rule like that, a TTL is a guess about how long a fact stays true, and a memory that expires wrongly is a fact the agent no longer has.
Some systems sort memories into kinds. SurrealDB Agent Memory applies a default seven-day TTL, counted from when each fact was known, to context facts and actions that have no valid_until of their own. Knowledge and identity facts are not subject to it. The expiry sweep runs hourly, so a fact past its seven days is closed at the next sweep: its valid_until is set to the current time, it leaves current reads, and it stays available for history and point-in-time reads. Importance decay is separate. A daily pass multiplies importance by a category rate (0.95 for context, 0.995 for knowledge, none for identity) and never changes whether a fact is valid. The kind of memory should set the clock, not one number for everything.
AWS's guidance on AgentCore memory suggests setting TTL by memory type: 30 to 60 days for summary memories and 6 to 12 months for semantic memories. For procedural memories it suggests considering no TTL, with validity checks as workflows change. The post's own solution defaults to 90 days for episodic memories. These are the post's suggestions, not measured results, so start from them rather than copy them.
To find your own numbers, sample. Take twenty stored memories of one kind, check each against its source, and count how many are still true after 30 days. The stale share shows how fast that kind changes. A fact one source can overturn, such as a price, takes that source as its clock. A fact only a person can overturn, such as a preference, waits for a person to replace it, not for a timer.
When should a memory expire on an event instead of a clock?
When the fact depends on a source, re-check the memory when that fact changes. Ask of each memory what it was read from: the page, document or record it came from. A change to the fact the memory holds triggers re-verification, an update or retirement. A redesigned page or an edit to unrelated content does not change the fact, so it should not retire the memory on its own. Botnet's guide draws a similar split: scheduled expiry for fast-changing classes like pricing, event-driven retirement for updatable facts, and no expiry on write age alone, since a fact confirmed yesterday is young whatever day it was first saved.
| Approach | Fits | Fails when |
|---|---|---|
| Clock (TTL) | Fast-changing facts, or records a retention rule governs | A fact stays true longer than its clock, such as an allergy |
| Decay | Facts that lose relevance gradually | Old facts that are still true lose weight with nobody reconfirming them |
| Event | Facts that depend on a source | The update path never learns that an older memory exists |
| No expiry | Facts that stay valid until a newer fact or a changed source replaces them | Stale facts stay in retrieval unless something supersedes them |
Event-driven expiry costs more to build. The write path has to be wired to the index, so an update can find the memories it replaces. A clock needs none of that. Botnet suggests starting the TTL generous and tightening it from the audit log, so an aggressive first rule does not delete facts users still need.
A source that changes once a year does not need a hook on every update. For a deadline that recurs each year, such as an enrollment window, re-check the source around the date the window closes. The memory is then retired when the thing it describes ends, not when it has been stored long enough.
For records of what the agent did, age is a trigger for review, not a reason to delete. A task blocker from three weeks ago should be checked, not expired by default: is the task done, is the blocker lifted, and when was its status last confirmed? Retire it on one of those states. A stable workflow rule can consider no fixed TTL. That means no clock removes it, not that it is exempt from review: re-check it when the process, its tools or the rules behind it change.
Should a person approve what an agent forgets?
Tigerless Labs' agent-memory decides by value rather than by a clock on each memory. Writes fire at conversation boundaries, so the agent does not have to remember to save. A sleep-time Manage pass consolidates memories and forgets by value, and it can add and update memories without a person in the loop. An update can supersede an older memory without erasing its history: the chain stays intact, and recall --as-of reads the earlier version as of a date (README). Recall runs on three tracks: a deterministic index injected at session start, ranked BM25 recall with an optional vector index fused in, and the plain directory tree when both miss.
Forgetting by value means worth, not age, decides what stays, which puts the weight on the Manage pass. Claude Code and Codex CLI can share one store (README), and the Markdown files remain the source of truth.
A person does not have to approve every act of forgetting. What matters is that forgetting can be undone: when an update supersedes an older memory and keeps its history, a wrong call costs a look at the earlier version rather than a lost memory.
Autoharness applies the same idea to Claude Code skills: it archives the ones that stop helping and touches only skills it created itself. An archive is not a deletion, since moving the folder back revives the skill. Where a tool does ask a person to confirm a removal, decide who reviews it before the first one is needed, because a queue that grows unread is worse than none.
Should an expired memory leave a trace?
It should, and the trace matters more than the clock. Botnet's guide advises logging every retirement and auditing the log monthly, because silent expiry leaves no way to answer why the agent forgot something. The log also shows whether a clock is right: a kind of memory that expires often while still in use is set too short. Keep each entry to the reason, the memory's kind, its source and the date.
SurrealDB keeps the trace by design: an expired fact gets an end date and stays in the entity's history. Its forget call is soft by default, and a separate purge step erases content. Soft expiry suits a store that must answer what was true at a given time, but it does not meet an erasure rule: where a rule requires deletion, purge the record.
When is a fixed expiry the wrong tool?
A fixed expiry is the wrong tool for a fact that stays valid without anyone reconfirming it. An allergy, a legal name or a standing preference stays valid until a newer fact or a changed source replaces it, so a clock that removes it gives the agent a wrong answer. Mem0 calls this over-eager forgetting, where a user says "I told you yesterday" and the agent has no record. A TTL set shorter than the user's recall interval is one possible cause, and Mem0 suggests a salience floor so that important facts cannot be pruned on time alone. Before blaming the clock, check in order: whether the fact was written, whether an expiry or delete removed it, and whether retrieval returned it.
The opposite failure is stale facts that survive. If the user moved cities and never said so, the agent keeps recommending restaurants in the old city, and no clock fixes that. Mem0 suggests time-based decay on top of supersession, so an old fact loses retrieval weight even without a contradiction. A confident answer built on a stale fact is harder to catch than a missing one, because the reply reads as normal.
The two failures have different costs. A deleted allergy can hurt someone; a stale restaurant tip only wastes a reply. Set the clock conservatively for facts where a miss is costly, and let decay and review handle the rest.
A fixed expiry is the right tool when a rule requires it, and the wrong one when it stands in for a judgment about the fact. Sort your memories into those two groups before you set any clock.
Conclusion
The right expiry is the one that matches how fast the fact goes stale. Put a clock on what ages on a calendar and an event on what changes with its source. What stays valid until a newer fact or a changed source replaces it gets no fixed clock, though it still gets re-checked. A long-lived fact should not lose its validity just because it is old. Use a fixed TTL where a retention rule requires one. Tigerless Labs' agent-memory is one tool built around that split.
Pick the three memories your agent saved most often this month and check whether each would still be true next quarter. Anything that fails the check needs a source or a clock. The rest can stay as they are.
FAQ
Do agent memories expire on their own?
Not in OpenSearch's agentic memory by default. It accumulates memories indefinitely until an administrator enables retention and sets a policy. Where a policy exists, a background job deletes memories past their age or count limit on a schedule, not the moment the limit passes.
Does expiring a memory delete it?
Not always. SurrealDB's agent memory closes a fact's validity and keeps it in the entity's history, so it leaves current retrieval but can still be inspected. OpenSearch's retention policy deletes records that pass its rules. Check which behavior your tool has.
Can an agent delete its own memories?
It depends on the tool. OpenSearch's retention job deletes records that pass its policy with no person involved. Tigerless Labs' agent-memory forgets by value in a sleep-time Manage pass, and an update can supersede an older memory while keeping its history.
Why does an agent forget something I told it yesterday?
Check in order: whether the fact was written, whether an expiry or delete removed it, and whether retrieval returned it. A TTL set shorter than the user's recall interval is one possible cause, as Mem0 describes it.
Should expired memories be kept for audit?
Where history must be traceable, yes. Botnet's guide advises logging every retirement and auditing the log monthly. Where a rule requires erasure, the record must be purged, not only expired.
Sources
- Agentic memory retention | OpenSearch Documentation
- Caching and invalidation, auto-expiry TTL | SurrealDB Agent Memory docs
- Forgetting memories | SurrealDB Agent Memory docs
- Memory eviction and forgetting in AI agents | Mem0
- Designing lifecycle policies for AgentCore memory | AWS Machine Learning Blog
- When Should I Expire Stale Agent Memories? | Botnet
- How Do I Expire Stale Agent Memories? | Botnet
- Agent Memory reddit thread, r/AI_Agents
- agent-memory | Tigerless Labs
- tigerless-labs/agent-memory, design commitments (GitHub README)
- AutoHarness | Tigerless Labs
- cost-xray | Tigerless Labs
