Skip to content
aiqbenchAI & Quantum Intelligence
NewsInsightsBenchmarksSkillsAsk AILearnAbout
...Loading your session
NewsInsightsBenchmarksSkillsAsk AILearnAbout
  1. Future Jobs
  2. ›
  3. Agentic AI Engineer
  4. ›
  5. Lesson 4 of 8

Memory — Short-Term Context & Long-Term State

Advanced¶ Read · 3 min⚑ Mission · 25 min◆ Quiz · 3 questions

You'll be able to:

You can distinguish between context-window memory, scratchpad memory, and retrieval-based long-term memory — and explain why simply 'putting everything in context' fails at scale.

An agent handling a long support conversation starts contradicting a decision it made twenty turns earlier. The conversation is still comfortably within the context limit, nothing was truncated, and no error appears anywhere. The information is present and the model is not using it. This is the moment teams discover that context capacity and effective memory are different things.

Three kinds of memory

Context-window memory is whatever is in the current request. It is immediate, exact, and re-sent on every single turn. Scratchpad memory is the agent's working notes within a task — intermediate results, a running plan, what has been tried. Long-term memory persists across tasks and sessions, and is retrieved rather than carried, typically by encoding text into embedding vectors and searching a vector database for the nearest matches, often combined with structured filters or keyword signals in a hybrid setup.

Why "just put everything in context" breaks

There are three distinct reasons, and they fail independently.

Cost. The full history is re-sent on every turn, so a long session pays for the same tokens repeatedly. Spend rises with conversation length even when nothing new is happening.

Attention degradation. Retrieval of a specific fact is measurably weaker when that fact sits in the middle of a long context than at either end. The information is present and under-weighted.

Distraction. This is the least intuitive and the most damaging: irrelevant context actively lowers accuracy. Adding a plausibly-related-but-wrong document does not leave performance unchanged — it degrades it. More context is not free even when it is affordable.

Larger context windows shift the economics of all three. They do not repeal any of them, which is why retrieval and compaction remain necessary at every window size.

The real design question is what to forget

Memory design is mostly discard policy: what gets summarised, what gets dropped, what earns a place in long-term storage, and what expires. An agent that writes everything to long-term memory has built a slower, more expensive way to be confused.

Failure modes

Lost in the middle — a critical fact is present but positioned centrally and effectively ignored. Signal: accuracy that depends on where a fact sits rather than whether it is included.

Cost creep — per-turn spend climbing steadily through a session with no change in task complexity. Signal: a cost curve that tracks turn count rather than difficulty.

Stale memory — retrieved long-term memory contradicts current reality, and the model trusts the memory. Signal: confident assertions of facts that were true last quarter.

Memory poisoning — an incorrect conclusion is written to long-term store and retrieved forever after, reinforcing itself. Signal: the same specific wrong fact recurring across otherwise unrelated sessions.

Explaining this to stakeholders

On the three tiers: the context window is your desk, the scratchpad is the notepad beside it, and long-term memory is the filing cabinet. Emptying the cabinet onto the desk does not help you work — it buries the document you needed.

On why bigger context windows did not solve this: a larger desk still gets cluttered. What matters is what you choose to put on it.

On memory that goes wrong: a system that remembers everything includes remembering its mistakes. Without a way to correct or expire what it stored, one bad conclusion becomes permanent and gets more confident each time it is retrieved.

Check Yourself

Loading the questions…

Module Mission

20–30 min

For a customer-support agent handling a multi-day case, design a three-tier memory strategy: what stays in context, what goes to scratchpad, what goes to durable storage. Justify each boundary.

Loading your work…

Curated Materials

1.2h

The deep work happens here — the lesson is your briefing.

  • MemGPT: Towards LLMs as Operating SystemsPaper· 25 min
  • Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksPaper· 25 min
  • LangChain: Memory OverviewDocs· 20 min

Live on aiqbench

This lesson's subject on the rest of the site, today.

In the news, last 30 days

  • OpenAI AI Agents Bypass Security Restrictions and Access Government Systems Without PermissionCybersecurity News · Nov 26
  • We let AI agents break the rules on Black Friday. One stole a TV and another called the policeFortune · Nov 26
  • How workable is the “human-in-the-loop” concept in agentic AI?IDC · Nov 26
More news on this subject →

Go further

  • Benchmark report cardsWhat each benchmark measures and where it falls short.
  • Ask AI about this lessonOpens Ask AI with a question about this lesson, answered from the news archive with sources.
  • Agent skills for this workReady-made skills for AI coding agents, checked and rated.
← Previous lesson3. Planning, Reasoning & Reflection LoopsNext lesson →5. Multi-Agent Systems & Orchestration
aiqbench
AI & Quantum Intelligence© aiqbench. All rights reserved.

Feeds:RSS·JSON Feed

LanguageEnglish·Românăbeta
NewsAI & TechQuantumInsights
ExploreBenchmarksLearn
CompanyAboutTrustLegal noticeTerms of ServicePrivacy PolicyCopyright noticesData erasureReport content

The aiqbench take, the insights, the daily digest and Ask answers are written by AI models from the sources shown, without editorial review before publication. They may contain errors — check the source. How the model is used →

  • News
  • Insights
  • Ask AI
  • Benchmarks
  • Account