Skip to content
all lessons
Agents in Practice6.16Locked

Memory across sessions

Close the session and the context is gone. So how does an agent 'remember' your project?

The idea inside

Memory lives outside the context window in notes files and saved facts, reloaded on demand.

After this lesson

You can explain how agents persist memory across sessions (notes/files/retrieval) outside the context window.

Where it leads

You can drive the tools, now see how teams ship and run LLM features in production.

Inside this lesson

That's the real lesson stage, paused. Claim your pass to operate it.

See how AI actually works, end to end.

This lesson is one stop on the full arc. Unlock all of it, and keep it for life.

What you get

  • The 34-lesson main path, a finishable route from a word to agents
  • Goal tracks for using AI at work and building AI features
  • Boss labs that make you apply a whole act, not just recognize it
  • Spaced recall that brings each idea back before you forget
  • Course memory: every term defined, with links to where it first appears
  • A shareable capability card when you finish the main path
  • Lifetime access on every device, every future lesson included

Not videos to watch. You predict, operate the machine, then prove it. That is why it stays.

99 interactive lessons and challenges. No videos, no code.

Free launch pass: lifetime access, no card needed

New here? The first lessons are free to try. Start with lesson 0.1

What this lesson shows

Memory lives outside the context window in notes files and saved facts, reloaded on demand.

The question it opens with

Close the session and the context is gone. So how does an agent 'remember' your project?

The walkthrough, in the lesson's own words

  • Close the tab. Watch the facts, then predict what happens to them.
  • Now give it an external memory. Toggle it, reopen, then try deleting a fact.
  • Session 3 loads the notes, wrong line included, and believes them.
  • Memory cuts both ways. Slip one wrong line into the notes.
  • Short-term lives in the window; long-term lives in files.
  • The tab is closed and the context window is cleared. So how does the agent 'remember' your project next time?
  • Tempting, but no, there's nothing to remember with.
  • Close! Re-reading is exactly the fix, but only if someone wrote the facts down first. By default nobody did.
  • The facts are gone. The model has no hidden store, wipe the window and the conversation never happened. By default the next session starts blank.
  • The context window (lesson 6.2) is the agent's short-term memory: it can reason over everything inside it freely, but only while the session stays open.
  • I don't have any information about this project. Could you tell me?
  • Amnesia by default: a fresh window each session. Nothing carries over, the agent forgot your whole project.
  • Hmm, nothing in my notes about report deadlines. When are they due?
  • Fridays. I loaded it from your notes file before we started.
  • The facts never lived in the model, they lived in a file the agent reloads on startup.
  • When ChatGPT says "memory updated", it did exactly this: it wrote one fact like these into a saved-memories file it reloads for every new chat.
  • Between sessions the model holds nothing. The notes file sits outside the window, so when a fresh session opens the agent reads that file back in, and the project's memory survives the wipe.
  • Only what the agent or app explicitly writes down gets stored, and it stays readable: a notes file you can open, or a settings page (ChatGPT lists every saved memory there). Delete a line and only that fact is forgotten, exactly like the ✕ above.
  • One anti-pattern to avoid: never write secrets (passwords, where keys live) into notes that get pasted into every session. Anything that reads the context, any tool, any person, sees them too.
  • Loaded and believed. The agent can't tell a true note from a planted one: one wrong line now misleads this session and every future one, the same way a weakened test in 6.12 fakes green forever.
  • Now delete the wrong line above to heal the memory.
  • Fixed, by editing the file, not the model. Whoever can write to the notes writes the agent's beliefs, so review what your agent saves.
  • Three ways: the fact goes stale (the schedule changed, the note didn't), the agent draws a wrong conclusion and saves it, or a page or email the agent reads tricks it into saving a line, that's prompt injection, lesson E.9. Treat saved memory like meeting minutes: worth a quick review.
  • Long-term memory lives outside the window, notes files like CLAUDE.md, saved facts, a database the agent searches and pastes back in (that's RAG, from lesson 5.2). The agent writes durable things down and reloads them on demand, so a brand-new session can pick up where the last one left off. The model never 'remembers', its tools do.
  • A support chatbot keeps forgetting a customer's account details the moment they start a new conversation. Why, and how would you fix it?
  • The context window is short-term memory: it is wiped at session end, so a fresh chat starts blank. Give the agent long-term memory: store the customer's details outside the model (a notes file or a database) and load them back in when each new session opens.
  • Two memories: a short-term context window erased at session end, and long-term files that survive and reload.

Key takeaway

You can give an agent durable memory by writing it down outside the window, not by hoping it remembers.

What you can do after this lesson

You can explain how agents persist memory across sessions (notes/files/retrieval) outside the context window.

Check yourself: How does an agent 'remember' across sessions?
  • By writing to memory outside the window (notes/files) and reloading it(correct)
  • It keeps the context window forever
  • It retrains itself each session
  • It can't remember anything, ever

It writes notes or files outside the context window and reloads them next time. The window itself is wiped each session; durable memory lives outside it.

Where it leads: You can drive the tools, now see how teams ship and run LLM features in production.

This is the written summary. The lesson itself is interactive: you predict, drag and operate the mechanism above, and the reveal answers you.