https://t.co/8itwqMgeoe
TL;DR · AI 摘要
mem0 on X: "Correcting Memory in Consumer Agents" / X mem0 @mem0ai $ /$ Correcting Memory in Consumer Agents 5 min read...
核心要点
- 主题聚焦:未命名内容
- 来源:mem0(@mem0ai),建议结合原文判断细节。
- AI 分析暂不可用,本条为保底评分与摘要。
mem0 on X: "Correcting Memory in Consumer Agents" / X
mem0
@mem0ai
$
/$
Correcting Memory in Consumer Agents
5 min read
A companion app with memory will sometimes remember something wrong. Imagine a user, Kai, who tells a daily companion app that their sister and her partner Jo are coming to stay for the weekend. A week later, the companion asks: "How's Jo? Are you two still planning that trip?" Jo is the sister's partner, and Kai is single.
Kai corrects it. If the companion replies "sorry, noted" and asks about Jo again a few days later, the correction changed nothing, and Kai has to make it again.
A correction tells the app which memory is wrong and what the right version is. If the app stores it as one more chat message, the wrong memory still stays in place.
Last week's article, Measuring Whether Memory Is Working in a Consumer App, covered how to count corrections. This article covers what to do with each one: the three kinds of correction, how to remove a memory that was never true, how to trace a wrong memory to the message that created it, and how to set it up on Mem0.
Three kinds of correction
- Let's say Kai lived in Porto and then says "I moved to Braga". Both facts were true at different times. "User lives in Porto" is now history, and the agent may still need it to ask how the move went.
- When Kai says "Jo is my sister's partner, not mine", the old memory was never true. If it stays as history, it can still reach the agent as "User's partner is Jo".
- Finally, when Kai says "Forget where I live", the memory may be true. But Kai wants it gone, along with any older versions.
Kai's latest message
The old memory
What the app should do
"I moved to Braga"
True, now outdated
Keep it as history
"Jo is my sister's partner, not mine"
Never true
Delete it
"Forget where I live"
True, unwanted
Delete it and its older versions
A memory layer that keeps history handles the first kind on its own. A newer fact replaces the older one, and the older one stays on record. The other two kinds need to be handled by the app.
Handling a correction
- Store the correction like any other message. Send Kai's message through the normal write path. The memory layer reads it with the user's recent messages and related memories, so it can tell which Jo Kai means. Before the next reply, read current facts only.
- Find the memory the agent used. If you log the ID of every memory that goes into a prompt, as last week's article suggested, the correction points straight at the wrong memory. Check whether the new write marked it as replaced.
- Delete what was never true. Delete the wrong memory by its own id, whether or not it was marked as replaced. If it was not replaced, the agent still sees both versions. If it was, it stays on record as the history of something that never happened.
- Check the memories that lean on the mistake. “User’s partner Jo likes hiking” and “User and Jo are planning a trip to Rome” carry the same error, and the correction may miss them. Search for “Jo” and fix only the wrong hits, because the search might also return some correct ones like “User’s sister’s partner Jo is a chef”.
- Let the user fix it. Some consumer apps have a "what I remember about you" screen. Show current facts only, and let the user edit or delete a row. Keep the old text of each edit on record.
Finding where a wrong memory came from
Before you fix a memory, you need to find why it was wrong. Keep a history of every change to each memory, with the messages behind it. The source messages usually point to one of three causes.
- The user's words were ambiguous. "My sister and her partner Jo are coming to stay. Jo and I are going hiking on Saturday." Read quickly, the second sentence makes Jo sound like Kai's partner. Delete the memory. If the same mix-up comes back across users, add an example to your extraction rules.
- The agent's words were stored as the user's without clear agreement from the user. The companion said "Sounds like you're nervous about starting at the bakery", and Kai said "maybe". If a memory reads "User is nervous about the bakery job", it came from the companion's sentence. Delete it, and store the agent's guess only when the user clearly agrees. Telling Your Agent What to Store and What Not To covers how to write that rule.
- The user did say it. Kai says "I never told you I was moving", and the history holds Kai's own message about Braga from November 2. The user decides what is true now, and the history only shows what was said. Act on the correction, and use the date to ask: "You mentioned Braga in early November. Did the plans change?"
Setting it up on Mem0
Mem0 writes are append-only. An add never changes the text of an existing memory. When a new message clearly contradicts an older memory, Mem0 stores the new fact as a new memory, marks the old one as superseded , and links it to the new one through replaced_by . An add also reads the user's recent messages and related memories, so you only send the new message.
python
from
mem0
import
MemoryClient
client
=
MemoryClient
()
# 1. Store the correction like any other turn
client
.
add
(
[{
"role"
:
"user"
,
"content"
:
"Jo is my sister's partner, not mine. I'm single."
}],
user_id
=
"kai"
,
)
# the add returns status PENDING and finishes in the background, within seconds
# 2. Before the next reply: current facts only
client
.
search
(
"Who is Jo?"
,
filters
={
"user_id"
:
"kai"
},
latest_only
=
True
)
# 3. Check the memory the agent used, read its history (below), then delete it
old
=
client
.
get
(
used_memory_id
)
print
(
old
[
"memory"
],
old
[
"lifecycle_state"
],
old
[
"replaced_by"
])
client
.
delete
(
used_memory_id
)For Kai, the add stores two new memories, and the old one points to the second:
User is single.
User does not have a partner; Jo is the user's sister's partner, not the user's partner.
User's partner is Jo superseded <id of the second new memory>The same add can also mark a related memory, such as "User's partner Jo likes hiking", as superseded, and leave another, such as the Rome trip, active.
Some important details:
- Pass latest_only=True on every read the agent uses. A default search or get_all still returns superseded memories without marking them. client.get(memory_id) returns lifecycle_state, such as active or superseded, and replaced_by.
- Delete the wrong memory by its own id. delete(memory_id, delete_linked=True) deletes a memory and every older version it replaced. Use it on the current memory for "forget where I live". When called on the new memory after a correction, it deletes the correction along with the older wrong memory.
- Use update for fixes and memory-screen edits. The memory keeps its id, search uses the new text, and history() gains an UPDATE entry with old_memory and new_memory.
# Kai edits one row on the memory screen
memories
=
client
.
get_all
(
filters
={
"user_id"
:
"kai"
},
latest_only
=
True
)[
"results"
]
client
.
update
(
memory_id
,
text
=
"User's sister's partner is named Jo"
)
# Related memories, after a person or a model has checked each hit
hits
=
client
.
search
(
"Jo"
,
filters
={
"user_id"
:
"kai"
},
latest_only
=
True
)[
"results"
]
for
memory_id
,
text
in
checked_fixes
:
client
.
update
(
memory_id
,
text
=
text
)- batch_update changes up to 1,000 memories in one call and writes no history entry. Use update in a loop when you want each fix on record.
Tracing a memory: client.history(memory_id) returns every change to a memory, newest first. Each entry has event (ADD, UPDATE or DELETE), old_memory, new_memory, updated_at for the time of the change, and input, the messages that created the memory. Read the history before you delete the memory.
for
entry
in
client
.
history
(
memory_id
):
print
(
entry
[
"event"
],
entry
[
"updated_at"
],
entry
[
"old_memory"
],
"->"
,
entry
[
"new_memory"
])
print
(
entry
[
"input"
])For a memory written from Kai's weekend message, input holds both turns (sample):
ADD <updated_at> None -> User and Jo are going hiking on Saturday, <date>
[{'role': 'assistant', 'content': 'Any plans for the weekend?'}, {'role': 'user', 'content': 'My sister and her partner Jo are coming to stay. Jo and I are going hiking on Saturday.'}]TypeScript names: latestOnly, delete(memoryId, { deleteLinked: true }), history(memoryId), batchUpdate.
If you are building a consumer app and your agent keeps getting a correction wrong, send us an example and we will help you trace it.
References
- Mem0 App
- Mem0, Memory History
- Mem0, Update Memory
- Mem0, Delete Memory
- Mem0, Search Memory
- Telling Your Agent What to Store and What Not To
- Measuring Whether Memory Is Working in a Consumer App
Written by @RudrajMehta , Product, Mem0
Memory Layer for your AI agents. Open source:
github.com/mem0ai/mem0
More Articles
Join 20.8K followers
4:04 PM · Dec 1, 2026
·
2,833
Views
1
5
35
33