systemdesign.academyAI EngineeringFree lessonsSign inGet the course
  1. Home
  2. AI Engineering: Data, RAG and Agents
  3. Agents in Production
  4. Agent Memory and Context: What the Model Sees, and What It Forgets

AI Engineering · Agents In Production

Agent Memory and Context: What the Model Sees, and What It Forgets

Free preview: the first part of this 11-part lesson.

Already bought the course? Sign in to read the whole lesson.

this lesson is part of

AI Engineering

Unlock this lesson and the 199 other paid lessons

  • 210 lessons in 16 chapters
  • 118 lessons built on a lab that really ran
  • An AI tutor beside every lesson that answers and draws
  • Lifetime access, every new lesson included

$49 once, by PayPal

See the AI Engineering course

The rest of this lesson

  1. Two Different Problems People Call Memory
  2. Working Memory, Session Summary, External Store
  3. Why Working Memory Fills Up and What It Costs
  4. When the Transcript Will Not Fit: Three Bad Choices
  5. Watch Truncation Drop a Fact the Agent Needs
  6. Context Is Not Free Even Below the Limit
  7. Long-Term Memory Is the RAG Problem Again
  8. Compaction Can Silently Delete a Safety Rule
  9. Managing Memory Is a Reliability Lever
  10. Knowledge Check

read the rest of this lesson in

AI Engineering

Unlock this lesson and the 199 other paid lessons

  • 210 lessons in 16 chapters
  • 118 lessons built on a lab that really ran
  • An AI tutor beside every lesson that answers and draws
  • Lifetime access, every new lesson included

$49 once, by PayPal

See the AI Engineering course

Continue this lesson

in Agents In Production

This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.

One-time payment. Lifetime access. No subscription.
Global
$49/lifetime

One-time payment via PayPal

Get Lifetime Access

Where this shows up in interviews

This idea carries a full system design question on its own. Each walks through the full answer.

  • →Design a Multi-Agent System
Previous lessonDurable Execution: An Agent Run Is a Workflow, Not a RequestNext lessonMulti-Agent Systems, and When Not to Build One

System Design

  • Foundation
  • Intermediate
  • Advanced
  • Capstone

AI Engineering

  • Foundation
  • Data, RAG and Agents
  • Evaluation, LLM Ops and Security

systemdesign.academy

  • Home
  • Glossary
  • Interview prep
  • Reviews
  • About
  • Pricing
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact
Foundation lessons free, try before you buy
India Special
India
₹999/lifetime

One-time payment: UPI, card or netbanking

Get Lifetime Access
Foundation lessons free, try before you buy
Every ML Platform lesson, Foundation to Advanced
Real architecture diagrams with real tool logos
MLOps, LLMOps, and data engineering in depth
Quizzes with instant feedback
Built and reviewed by senior engineers
Lifetime access, all future content included

Foundation lessons of this course are free, no payment needed. Try them now

What Does the Model Remember Between Steps?

Nothing. The model remembers nothing between steps.

A language model is stateless. It does not carry anything from one call to the next. So on every step of the loop from lesson one, the orchestrator resends the entire conversation so far: the goal, every action the model took, and every observation that came back. That block of text is the only thing the model sees. It is not remembering the task. It is rereading a transcript you hand it, from the top, every time.

This one fact drives the whole lesson. If the model only knows what is in the transcript on this step, then two things decide how the agent behaves: what you put into that transcript, and what you leave out. Both are choices, and both are yours. The word "memory" hides that. It makes the transcript sound like something the model owns and manages. It does not. You manage it, or it manages you by growing until it breaks.

It helps to see what actually occupies that transcript on a single step, because "memory" is not one undifferentiated blob. It is a fixed token budget, and several different things compete for the same space: a small block of system instructions and safety rules, the schema of every tool in scope, whatever long-term facts you retrieved for this step, a compressed summary of older turns, and the recent turns kept word for word. Each line has a different cost and a different claim on being kept.

Stacked context-window budget bar for one agent step against a 32,000 token working budget, split into system and safety at 1,800 tokens, tool definitions at 3,400, retrieved facts at 1,200, session summary at 900, recent verbatim turns dominating at 21,700 tokens or 68 percent, and free headroom of 3,000, with a legend explaining each line item

Notice which line dominates. The verbatim recent turns are more than two thirds of the budget on their own, while the fixed lines at the top, the system prompt and the tool schemas, are cheap. That single fact is why cost balloons on a long run and why, when the budget is blown, every cutting decision revolves around those recent turns and almost never the small fixed blocks.