# Mission 14.2: It still says I live in Leipzig

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-14-2

Belongs to [Chapter 14: Memory and second brains](https://llm.yoga/en/14-gedaechtnis.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Nils**, field sales rep:

> “Three weeks ago I told our AI assistant that I’d moved to Dresden. It’s even in the list of what it has remembered. But it still plans my customer appointments from Leipzig and writes in emails that I’m based there. Did it not understand me?”

As soon as the assistants on your team have a memory, complaints like this land on your desk, and you need to be able to say quickly where things go wrong. The assistant pulls facts out of conversations and files them in a list, its memory. Before every answer, a program picks matching entries from it and puts them into the prompt, the request to the language model.

**Question 1 (prediction):** What probably happened in the memory?

- A) The move was never saved; the model didn’t catch it.
- B) The model knows Leipzig from training and sticks to it.
- C) The move was added as a new entry, and the old place of residence stayed.

## What’s behind it

Picture an address book where someone writes the new address below the old one without crossing out the old one. Whoever reads the top line first keeps sending the mail to Leipzig.

That’s what happens to a memory that only appends new facts. Then there’s **retrieval**: before every answer, only a limited selection of entries goes into the prompt, for example the five best matches. If the new entry falls out of that selection, the model only sees Leipzig.

There are four ways to deal with outdated facts. The simplest is a **fixed topic key**: every fact has a topic from a fixed list, such as place of residence, employer or diet, and a new entry on the same topic replaces the old one. That works for topics with only one valid value: you live in one place. For topics with several values, such as languages, new entries are added. The other ways: a timestamp, where the newer entry wins; a model that compares new information with what’s there when writing; a validity period, which ends “lives in Leipzig” instead of deleting it.

The key only helps if the model that pulls out the facts also files the move under the topic of residence. In the chapter’s exercise, the small model qwen3:1.7b, an open model with 1.7 billion parameters, filed the move under a different topic. The old place of residence stayed. The larger qwen3:8b filed it correctly, but needed an extra rule for that: only one fact per topic. For writing to memory, a stronger model pays off, and the result should be checked.

For Nils this means: have the Leipzig entry replaced or archived. And the memory should show what it stores, so that something like this gets noticed before the next email goes out.

### In more detail: Mem0, Zep and archiving

Mem0, a memory layer packaged as a library, takes the third way: it pulls facts out of conversations, merges them with existing ones and retrieves them later. Zep builds on Graphiti, according to the paper “a temporally-aware knowledge graph engine”. A relationship like “lives in Leipzig” gets an end there, and “lives in Dresden” a start. That way the agent can still say later where someone lived in the summer. Andrej Karpathy’s LLM Wiki has the model explicitly note where new sources contradict old ones when it works them in.

Many systems prefer archiving to deleting: the entry is kept for tracking but no longer shows up in any search. And keeping an eye on the growth rate helps: if a great many new facts are being added, the model is probably remembering too much.

In the script of the chapter exercise, the model only decides the topic and the statement; the script decides, based on the topic, whether to replace. Without the extra rule „Je Thema höchstens ein Fakt, als ganzer Satz.“ (German for “At most one fact per topic, as a full sentence.”; it stays German because that’s the prompt I measured), qwen3:8b on the test Mac on November 25, 2026 split the move three times in a row into three entries on the topic of residence, which replaced each other one after another; what remained was „letzten Monat“ (“last month”). With the rule, it replaced the residence correctly, and that’s how the chapter exercise has done it since November 25, 2026. The Mac exercise shows both.

## Try it

**Maintaining Nils’ memory**

**Task:** Three new statements come from the latest conversations with Nils. Decide for each what happens to it, so that the list is correct afterward and no answer has to guess.

**Stored so far:**
- lives in Leipzig (Conversation in March)
- works in sales, Central region (Conversation in March)
- speaks business-fluent English (Conversation in May)

**Possible actions for each statement:** Append · Replace · Don’t save

1. has moved to Dresden (Topic: residence · conversation three weeks ago)
2. speaks Polish (Topic: languages · conversation three weeks ago)
3. is pretty tired today (Topic: mood · conversation today)

## Check

**Question 2 (check question):** A colleague suggests: “Then we’ll just append every new fact. The model is smart enough to take the newest one.” What’s the problem with that?

- A) The model only sees a selection and doesn’t know which is newer.
- B) Nothing; a large model reliably recognizes contradictions.
- C) Duplicate entries take up unnecessary space in the database.

**Question 3 (check question):** You want a small, cheap model to pull the facts out of conversations. What do you watch out for?

- A) Nothing special; pulling out facts is a very easy task.
- B) Whether it files every statement under the right topic.
- C) Whether it’s fast enough that the user doesn’t wait for the answer.

## Done

**What you can do now**

- You can explain why a memory that only appends collects outdated and contradictory facts.
- You can tell when a new fact replaces an old one, when it’s added, and when it doesn’t belong in memory at all.
- When a customer says their assistant clings to old information, you ask whether its memory has topic keys or timestamps and which model writes the facts.

### Two cards for review

**Card 1:** True or false? “If two contradictory facts are in memory, the model automatically takes the newer one.”

**Card 2:** A script only replaces a fact when the topic is the same. The small model files “moved to Dresden” under “job”. What does the assistant say about the place of residence afterward?

- A) Dresden; the move replaced the place of residence
- B) Still Leipzig; the old entry is untouched
- C) Nothing; the script spots the mistake and saves nothing

- [Next mission: “Remember permanently: invoices to this IBAN”](https://llm.yoga/en/einsatz-14-3.md)
- [Try it on your Mac](https://llm.yoga/en/mac-14-2.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Who decides what gets remembered?](https://llm.yoga/en/14-gedaechtnis-2.md)
- [Forgetting, updating, contradictions](https://llm.yoga/en/14-gedaechtnis-2.md)
- [Retrieval: meaning, words and time](https://llm.yoga/en/14-gedaechtnis-1.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is C.
- A: That happens, but it doesn’t fit here: the move is in the list of remembered facts. A mere promise in the chat (“I’ll remember that”) wouldn’t prove anything; only the list or a receipt like “Remembered” shows what’s actually stored.
- B: There’s nothing about Nils in the weights, the knowledge from training. What the model knows about him comes only from the memory that’s put into the prompt before the answer.
- C, correct: A memory that only appends collects contradictions. If “lives in Leipzig” sits next to “has moved to Dresden”, the model has to guess, and if only the old entry makes it into the prompt, it’s sure to answer wrongly.

- Statement 1: **Replace:** Same topic, new status: the old place of residence has to go, or two will sit side by side. A system with an archive keeps “lives in Leipzig” but no longer pulls it into the prompt.
  - Append: Then Leipzig and Dresden sit side by side, and the model has to guess. If retrieval puts only the old entry into the prompt, it’s sure to say Leipzig. That’s exactly what happened to Nils.
  - Don’t save: The move is lasting and changes where the assistant plans appointments from. It belongs in memory.
- Statement 2: **Append:** Polish is added to English; both hold. Languages are a topic with several values; you only replace for topics with one valid value, like the place of residence.
  - Replace: Then English would be gone, even though Nils still speaks it. Replacing only fits topics with one valid value, as with the move.
  - Don’t save: A language stays valid for a long time and can determine which customers Nils takes on. That’s a fact, not small talk.
- Statement 3: **Don’t save:** A mood of the day won’t hold in a week. Only what should change future answers gets remembered; the conversation itself stays in the history.
  - Append: Then three months from now the prompt will still say Nils is tired. In the chapter’s exercise, the small model saved exactly a sentence like this despite the instruction.
  - Replace: There’s nothing under “mood” yet, so replacing just appends here. The problem remains: a mood of the day isn’t a fact.

**Maintaining Nils’ memory** Without JavaScript: each statement above has an “answer”. Afterward the list contains “has moved to Dresden” instead of “lives in Leipzig”, “works in sales, Central region”, “speaks business-fluent English” and “speaks Polish”.

**Question 2:** The correct answer is A.
- A, correct: Retrieval puts only a limited number of entries into the prompt. If the new one isn’t among them, the model doesn’t stand a chance. And without a date on the entry, it doesn’t know which one applies even when both are hits.
- B: A model can only weigh what’s in the prompt. If the new entry or its date is missing there, the size of the model doesn’t help.
- C: A few hundred short sentences are a few kilobytes. The problem is the contradiction between old and new, not the space.

**Question 3:** The correct answer is B.
- A: In the chapter’s exercise, qwen3:1.7b filed the move under the wrong topic, and the old place of residence stayed. The task isn’t easy.
- B, correct: The fixed key only replaces when the topic is exactly the same. If the model files the move differently, both places of residence stay. For writing to memory, a stronger model pays off.
- C: Speed is secondary here. A wrongly filed fact keeps affecting every future answer; a slow step only happens once.

**Card 1:** **False.** When memory is retrieved, often only a selection goes into the prompt, and the new entry is missing. Without a date, the model doesn’t know which one applies even when both are hits. Fixes: a fixed topic key for topics with only one valid value, like the place of residence, timestamps, or a comparison when writing.

**Card 2:** Correct: B, Still Leipzig; the old entry is untouched The key only applies when the topic is exactly the same. If the move lands under “job”, “lives in Leipzig” stays. That’s what happened in the chapter exercise with qwen3:1.7b. For writing to memory, a stronger model pays off.
