AgentFlare

Research · AI engineering · updated 2026-10-16

Context Engineering: Memory for AI Agents

Context engineering designs what information reaches an LLM at each step, and agent memory supplies what persists between sessions. Together they address the stateless nature of models, which many production agent failures trace back to.

Sources88 domains
Concepts6
Reading time6 min
RefreshedWeekly
402 · Pay-per-Crawl$0.02

You're reading the full report — free for humans and search engines. The same content ships as a structured JSON dataset (normalized facts, sources and citation arrays, no HTML parsing) so AI agents can consume it directly — metered per fetch via the open HTTP 402 payment protocol.

⚡ Agents: fetch .data.json · $0.02 → agents: crawlerAutoPrice=true · verify at https://esa.aisa.one/api/v1/access/verify

Large language models are stateless, so an agent's apparent memory exists only because developers decide what to store, when to load it, and when to discard it. Context engineering treats the finite context window as a scarce resource and designs retrieval, memory, tools and prompts around it. Agent memory is the external storage that survives session boundaries, while context engineering selects what gets loaded from that storage. Sources in this brief describe working, episodic, semantic, procedural, entity and workflow memory, plus operations such as writing, selecting, compressing and isolating context. This brief covers the core concepts, a memory pipeline, common failure modes, and design guidance for developers and AI agents building memory-aware systems.

4K to 200K tokensRange of finite LLM context windows citedS1 · medium.com
26aiOracle AI Database version featured in the sessionS4 · go.oracle.com

Key concepts

Context engineering
The discipline of designing the architecture that feeds an LLM the right information at the right time, covering retrieval, memory, tools and prompts, so the model spends attention on high-signal tokens. S2 · weaviate.ioS3 · mem0.ai
Context window
The maximum input a model can consider at once, measured in tokens. It includes inputs, outputs, tool calls and retrieved documents, and acts as the model's short-term memory. S2 · weaviate.io
Agent memory
External storage that survives session boundaries, such as files, databases and vector stores. Context engineering then selects what is loaded from it into the next session's window. S8 · augmentcode.com
Short-term versus long-term memory
Short-term memory persists within a session: conversation history, temporary variables, workflow state. Long-term memory is stored outside the window, such as user profiles and project context, for retrieval across sessions. S1 · medium.comS2 · weaviate.io
Forgetting and staleness
Forgetting is designed in as a feature, using TTLs, decay, freshness metadata and staleness detection, so agents do not act on facts that have stopped being true. S5 · hidekazu-konishi.com
Context failures
Common failures that derail agents: poisoning, distraction, confusion and clash. Each has mitigation techniques within context engineering. S6 · microsoft.github.io

A memory pipeline for agents

  1. Capture informationCollect inputs worth remembering from interactions, such as user input, system instructions, and retrieved documents, as the raw context sources.
  2. Encode itStructure information before it enters the model: plain text or JSON schemas, embeddings or symbolic forms, summaries or verbatim content.
  3. Store itPersist information outside the context window, in stores such as vector databases or relational and JSON databases, so it survives across sessions.
  4. Organize itStructure stored memory by type, such as working, episodic, semantic, procedural, entity and workflow memory, and apply summarization, compaction and indexing.
  5. Retrieve what is relevantPull only relevant items into the window at each step, using relevance scoring, recency weighting and importance thresholds.

Why agents need engineered memory

Large language models are stateless: every invocation starts from zero, knows only what sits in its context window, and forgets everything when the call returns. By default an LLM has only short-term memory, the current context window, which holds instructions, inputs, outputs, tool calls and retrieved documents. Everything an agent remembers exists because someone decided to store it, load it at the right moment, and eventually remove it. The sources attribute many production failures to context rather than the model: when an agent gives irrelevant responses or forgets previous interactions, the underlying LLM is usually working fine and the problem lies in the information being fed to it. Augment Code frames the split as agent memory, which determines what survives between sessions, and context engineering, which determines what is loaded into the next session's finite window.

Memory types and where they live

Oracle's session material lists working, episodic, semantic, procedural, entity and workflow memory, alongside short-term and long-term memory, summarization, compaction and semantic indexing. Medium's guide describes writing context as storing information outside the window for later retrieval; short-term memory persists within a session, covering conversation history, temporary variables and workflow state, while long-term storage holds items such as user profiles and project context. Weaviate says reliable agents combine the window with long-term memory retrieved from external stores like vector databases and selectively decide what to include at each step. Augment Code names three persistence layers: static context files for team-wide knowledge, agent memory for session-learned decisions with human curation, and living specs for evolving implementation intent. The design guide on hidekazu-konishi.com adds that forgetting should be designed in from the start through TTLs, decay, freshness metadata and staleness detection.

Context operations and failure modes

Microsoft's lesson frames four strategies for managing context: write, select, compress and isolate. The Medium guide similarly describes four fundamental operations, including writing context to persistent storage, reading relevant information into the window, and compressing context to reduce redundancy and verbosity while keeping essential information. Mem0 lists selection and filtering as deciding what to include and what not to include, using relevance scoring, recency weighting and importance thresholds, and says context poisoning and overload are addressed through adaptive memory updates and intelligent relevance filtering. Microsoft names poisoning, distraction, confusion and clash as common context failures to mitigate. Augment Code warns that adding more memory without engineering how it loads produces agents that drown in stale context, while precise context engineering without populated memory produces agents that start fresh every session.

Prompt engineering vs context engineering

AspectPrompt engineeringContext engineering
Core questionWhat words should I use?What configuration of context is most likely to generate the desired behavior?
ScopeA single set of static instructions guiding the agent with rulesA dynamic set of information, including the initial prompt, managed over time
FocusHow you phrase instructions, add examples, or ask for step-by-step thinkingArchitecture that gives the model retrieved data, tools and memory to ground its responses
LimitationCannot fix the limitation of a disconnected model on its ownAims to make the process repeatable and reliable

Timeline

  1. 2026-06
    Date of documentation underlying the agent memory design guide.hidekazu-konishi.com

Common pitfalls

  • Confusing agent memory with context engineering, or neglecting either, yields agents that forget critical decisions and resuggest rejected patterns.
  • Treating memory as an afterthought leaves agents repeating corrected mistakes or acting on facts that stopped being true; these are memory design problems, not model problems.
  • Irrelevant information can hurt performance through distraction or confusion, so loading everything into the window is counterproductive.
  • Prompt engineering alone cannot fix the fundamental limitation of a disconnected model that lacks access to private data or earlier conversation.

Key takeaways

  • Treat the context window as a scarce resource and design retrieval, memory and tools around it.
  • Decide deliberately what to store, when to load it, and when to forget it.
  • Separate persistent agent memory from context selection, and invest in both.

FAQ

What is context engineering for AI agents?

It is the practice of making sure an agent has the right information to complete the next step. It includes managing what is added to, removed from, and condensed within the limited context window.

How is agent memory different from context engineering?

Agent memory is external storage that survives session boundaries, such as files, databases and vector stores. Context engineering selects what gets loaded from that storage into the model's finite context window for the current session.

Why do LLM agents forget things?

LLMs are stateless and by default only have the current context window as memory. What looks like forgetting is a memory limitation, so persistence must be designed through storage and retrieval.

What are common context failures and how are they handled?

Microsoft lists poisoning, distraction, confusion and clash. Mem0 says poisoning and overload are addressed through adaptive memory updates and intelligent relevance filtering, while writing, selecting, compressing and isolating context help mitigate them.

How this page is made. Built from the full text of 8 sources found with the AISA Tavily API (advanced search), refreshed weekly. A language model organizes what those sources state into the blocks above; each block links the sources it draws on, and figures that do not appear in the sources are removed.

Sources & citations

  1. Context Engineering for AI Agents: The Complete Guide | by IRFAN KHAN | Medium medium.com
  2. Context Engineering - LLM Memory and Retrieval for AI Agents | Weaviate weaviate.io
  3. Context Engineering AI: How To Build Smarter LLM Agents In 2026 mem0.ai
  4. Introduction to Context Engineering and Agent Memory with Oracle AI Database go.oracle.com
  5. AI Agent Memory Design Guide - Working, Long-Term, and Procedural Memory with Forgetting and Staleness Management | hidekazu-konishi.com hidekazu-konishi.com
  6. Context Engineering for AI Agents | ai-agents-for-beginners microsoft.github.io
  7. Memory for AI Agents: A New Paradigm of Context Engineering - The New Stack thenewstack.io
  8. Agent Memory vs. Context Engineering: What Persists Between Sessions and What Doesn't | Augment Code augmentcode.com