cd /news/ai-agents/your-agent-remembered-the-old-number… · home › topics › ai-agents › article
[ARTICLE · art-176014] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Your Agent Remembered the Old Number. How to Correct What It Remembers

A developer published a guide on correcting stale facts in AI agent memory, explaining that a correction typically adds a new fact without removing the old one, which can persist across multiple storage locations. The writeup maps where memory lives in Claude Code (CLAUDE.md files plus auto memory under ~/.claude/projects/<project>/memory/), ChatGPT (saved memories, past chats, custom instructions, files and connected apps) and Gemini CLI (GEMINI.md files and per-project folders), and offers a read-only Python script that scans Markdown memory files for old and new values and reports each file's modified timestamp.

recommendation

After correcting an agent's remembered fact, grep every Markdown memory location for both the old and new values and delete or expire the stale copies rather than assuming the correction replaced them.

more in playbook: Designing agent systems
by read7 min views1 publishedNov 25, 2026

Two months ago the public API allowed 100 requests per minute. Then the limit dropped to 60, you told your agent, and it said it would remember. Today it sizes a retry loop for 100 again.

The agent didn't ignore you. Most likely it now remembers both numbers. A correction usually adds a new fact. It doesn't always remove the old one, and the old one can live in several places at once.

This article is about that cleanup: where a remembered fact actually lives, how to find every copy of it, and how to correct or expire it so it stops coming back. An earlier article covered how to scope memory and when to forget. This one starts after the damage is done: a wrong fact is already stored.

Before you can correct a memory, you need to know where it is. Three tools document this clearly.

Claude Code keeps two kinds of memory. CLAUDE.md files are instructions you write. Auto memory is notes Claude writes itself, and the memory docs list feedback ("corrections you give Claude and approaches you confirm") as one of the note types. Each project gets a folder at ~/.claude/projects/<project>/memory/ with a MEMORY.md index and one topic file per memory. The first 200 lines or 25KB of MEMORY.md load at session start, and topic files are read on demand.

Two details matter for stale facts. First, CLAUDE.md files are "concatenated into context rather than overriding each other". Second, the docs warn that "if two instructions contradict each other, Claude may pick one arbitrarily." That warning is about instruction files, but my reading is that the same risk applies when the old number sits in CLAUDE.md and the correction sits in auto memory: both reach the model, and nothing guarantees which one wins.

ChatGPT spreads memory over several sources. OpenAI's Memory in ChatGPT help page lists past chats, saved memories, custom instructions, saved files and connected apps, depending on plan and region. Saved memories "are stored separately from chat history", and the page says plainly: "Deleting a chat alone does not necessarily delete a separate saved memory created from that chat."

Gemini CLI stores memory as Markdown. Its memory tool docs say it routes facts to repository GEMINI.md files, a private per-project memory folder, or the global ~/.gemini/GEMINI.md.

The pattern is the same everywhere: one fact, several possible homes. A correction you type in chat lands in one of them.

Start with the tool's own view, not your guess.

/memory. It lists your CLAUDE.md and CLAUDE.local.md locations and lets you open the auto memory folder. The docs put it simply: "Everything is plain markdown you can read, edit, or delete."/memory show. The For file-based memory, the inspection can be scripted.

This small script searches Markdown memory files for an old value and a new value, and prints every line that holds either one. If a file has frontmatter with a modified timestamp, the script also prints its age. Claude Code records that field: according to the docs, when Claude writes a memory file that begins with YAML frontmatter, Claude Code adds modified as an ISO 8601 timestamp. The script only reads files and uses only the Python standard library.

#!/usr/bin/env python3
"""Find every place a remembered fact still lives in markdown memory files.
Reads only. Usage: python3 find_fact.py OLD_PATTERN NEW_PATTERN DIR [DIR ...]"""
import re, sys
from datetime import datetime, timezone
from pathlib import Path

old_pat, new_pat, dirs = sys.argv[1], sys.argv[2], sys.argv[3:]
old_re, new_re = re.compile(old_pat, re.I), re.compile(new_pat, re.I)
now = datetime.now(timezone.utc)

def frontmatter(text):
    m = re.match(r"---\n(.*?)\n---\n", text, re.S)
    return dict(re.findall(r"^(\w+):\s*(.+)$", m.group(1), re.M)) if m else {}

old_hits = new_hits = 0
for d in dirs:
    for f in sorted(Path(d).rglob("*.md")):
        text = f.read_text()
        meta = frontmatter(text)
        age = ""
        if "modified" in meta:
            mod = datetime.fromisoformat(meta["modified"].replace("Z", "+00:00"))
            age = f" (type={meta.get('type', '?')}, modified {mod:%Y-%m-%d}, {(now - mod).days} days ago)"
        for no, line in enumerate(text.splitlines(), 1):
            if old_re.search(line):
                old_hits += 1
                print(f"OLD  {f}:{no}{age}\n     {line.strip()}")
            elif new_re.search(line):
                new_hits += 1
                print(f"new  {f}:{no}{age}\n     {line.strip()}")

print(f"{old_hits} line(s) with the old value, {new_hits} with the new one")
if old_hits and new_hits:
    print("CONFLICT: both values are still stored. Fix or delete the OLD lines.")
sys.exit(1 if old_hits else 0)

I built a small demo to test it: a repo with a CLAUDE.md, and a memory folder laid out the way the Claude Code docs describe it (a MEMORY.md index plus topic files with type and modified frontmatter). I wrote the memory files by hand to match that layout; they are not a real Claude Code memory. The demo has the situation from the intro: the old limit in two places, the correction in another. This is the real output, run on 23 Nov 2026 with Python 3.13.5:

$ python3 find_fact.py "100 requests" "60 requests" repo home/.claude/projects/demo-repo/memory
OLD  repo/CLAUDE.md:4
     - The public API rate limit is 100 requests per minute per key
OLD  home/.claude/projects/demo-repo/memory/MEMORY.md:1
     - [Rate limit](project_rate_limit.md): public API allows 100 requests/minute
new  home/.claude/projects/demo-repo/memory/MEMORY.md:2
     - [Rate limit fix](feedback_rate_limit.md): user corrected the limit to 60 requests per minute
new  home/.claude/projects/demo-repo/memory/feedback_rate_limit.md:5 (type=feedback, modified 2026-11-18, 4 days ago)
     User corrected me: the public API rate limit is now 60 requests per minute per key.
OLD  home/.claude/projects/demo-repo/memory/project_rate_limit.md:5 (type=project, modified 2026-09-14, 69 days ago)
     The public API rate limit is 100 requests per minute per key. Use it when sizing retries.
3 line(s) with the old value, 2 with the new one
CONFLICT: both values are still stored. Fix or delete the OLD lines.
exit code: 1

Three copies of the old value. The correction exists, but the 69-day-old project note and the line in CLAUDE.md still say 100. The index lists both notes, so the old number loads at session start next to the new one.

Telling the agent "that's wrong" is a good start, but it only fixes the place the agent chooses to write. Fix each copy where it lives:

MEMORY.md line that points to it. In the demo, the old project note was deleted and the two index lines were merged into one. Here is the fix in the demo:

-- [Rate limit](project_rate_limit.md): public API allows 100 requests/minute
-- [Rate limit fix](feedback_rate_limit.md): user corrected the limit to 60 requests per minute
+- [Rate limit](feedback_rate_limit.md): public API limit is 60 requests per minute (corrected by user)
 - [Test runner](feedback_testing.md): use pnpm, never npm
Only in demo/home/.claude/projects/demo-repo/memory: project_rate_limit.md
-- The public API rate limit is 100 requests per minute per key
+- The public API rate limit is 60 requests per minute per key (changed Nov 2026)

And the same search afterwards:

$ python3 find_fact.py "100 requests" "60 requests" repo home/.claude/projects/demo-repo/memory
new  repo/CLAUDE.md:4
     - The public API rate limit is 60 requests per minute per key (changed Nov 2026)
new  home/.claude/projects/demo-repo/memory/MEMORY.md:1
     - [Rate limit](feedback_rate_limit.md): public API limit is 60 requests per minute (corrected by user)
new  home/.claude/projects/demo-repo/memory/feedback_rate_limit.md:5 (type=feedback, modified 2026-11-18, 4 days ago)
     User corrected me: the public API rate limit is now 60 requests per minute per key.
0 line(s) with the old value, 3 with the new one
exit code: 0

One value left, in every place.

Some facts change: limits, prices, versions, owners, deadlines. For those, my own rule (not something the docs require) is to write the date into the fact itself, like "(changed Nov 2026)" above. Then a reader, human or agent, can tell how current it is without opening a settings screen. Claude Code's modified timestamp does part of this for auto memory, but it records when the file was written, not whether the fact is still true.

It also helps to know what is not cleaned up for you. The Claude Code docs say memory files are excluded from the transcript retention sweep and "stay until you or Claude edits or deletes them". For your CLAUDE.md files and rules, /doctor prompt-audit asks Claude to look for outdated or conflicting instructions and propose edits; nothing changes until you ask Claude to apply them. In ChatGPT, the help page notes that deletion and memory updates "can take time" to propagate.

/memory reload, which re-scans the GEMINI.md files. If you want the basics behind all this, the free AI Agent Memory Quick-Start explains the four kinds of memory and the memory loop (extract, store, retrieve, use, maintain), including consolidation and forgetting, in 6 pages. For the four kinds of memory in article form, see Why Your AI Agent Forgets Everything.

Now I'd like to hear from you: what has your agent remembered wrong, and where did the old value turn out to live?

This article was written with the assistance of AI and reviewed by the author.

── more in #ai-agents 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/your-agent-remembere…] indexed:0 read:7min 2026-11-25 · —