{
  "@context": "https://agentflare.org/schema",
  "type": "Article",
  "tier": "L2-full",
  "title": "Context Engineering: Memory for AI Agents",
  "description": "Context engineering designs what information reaches an LLM at each step, and agent memory supplies what persists between sessions. Together they address…",
  "canonical": "https://agentflare.org/research/context-engineering-memory-for-ai-agents.html",
  "category": "research",
  "updated": "2026-10-16",
  "generated_at": "2026-10-16T00:37:01.652Z",
  "facts": [
    {
      "label": "Cluster",
      "value": "AI engineering"
    },
    {
      "label": "Sources",
      "value": "8"
    },
    {
      "label": "Updated",
      "value": "2026-10-16"
    }
  ],
  "data": {
    "topic": "context engineering and memory for AI agents",
    "cluster": "ai-eng",
    "generated_at": "2026-10-16T00:37:01.652Z",
    "tldr": "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.",
    "intro": "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.",
    "concepts": [
      {
        "term": "Context engineering",
        "definition": "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.",
        "sources": [
          "S2",
          "S3"
        ]
      },
      {
        "term": "Context window",
        "definition": "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.",
        "sources": [
          "S2"
        ]
      },
      {
        "term": "Agent memory",
        "definition": "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.",
        "sources": [
          "S8"
        ]
      },
      {
        "term": "Short-term versus long-term memory",
        "definition": "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.",
        "sources": [
          "S1",
          "S2"
        ]
      },
      {
        "term": "Forgetting and staleness",
        "definition": "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.",
        "sources": [
          "S5"
        ]
      },
      {
        "term": "Context failures",
        "definition": "Common failures that derail agents: poisoning, distraction, confusion and clash. Each has mitigation techniques within context engineering.",
        "sources": [
          "S6"
        ]
      }
    ],
    "how_it_works": {
      "title": "A memory pipeline for agents",
      "steps": [
        {
          "step": "Capture information",
          "detail": "Collect inputs worth remembering from interactions, such as user input, system instructions, and retrieved documents, as the raw context sources.",
          "sources": [
            "S4"
          ]
        },
        {
          "step": "Encode it",
          "detail": "Structure information before it enters the model: plain text or JSON schemas, embeddings or symbolic forms, summaries or verbatim content.",
          "sources": [
            "S3"
          ]
        },
        {
          "step": "Store it",
          "detail": "Persist information outside the context window, in stores such as vector databases or relational and JSON databases, so it survives across sessions.",
          "sources": [
            "S2",
            "S4"
          ]
        },
        {
          "step": "Organize it",
          "detail": "Structure stored memory by type, such as working, episodic, semantic, procedural, entity and workflow memory, and apply summarization, compaction and indexing.",
          "sources": [
            "S4"
          ]
        },
        {
          "step": "Retrieve what is relevant",
          "detail": "Pull only relevant items into the window at each step, using relevance scoring, recency weighting and importance thresholds.",
          "sources": [
            "S1",
            "S3"
          ]
        }
      ]
    },
    "sections": [
      {
        "h": "Why agents need engineered memory",
        "body": "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.",
        "sources": [
          "S2",
          "S3",
          "S5",
          "S8"
        ]
      },
      {
        "h": "Memory types and where they live",
        "body": "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.",
        "sources": [
          "S1",
          "S2",
          "S4",
          "S5",
          "S8"
        ]
      },
      {
        "h": "Context operations and failure modes",
        "body": "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.",
        "sources": [
          "S1",
          "S3",
          "S6",
          "S8"
        ]
      }
    ],
    "comparison": {
      "title": "Prompt engineering vs context engineering",
      "columns": [
        "Aspect",
        "Prompt engineering",
        "Context engineering"
      ],
      "rows": [
        [
          "Core question",
          "What words should I use?",
          "What configuration of context is most likely to generate the desired behavior?"
        ],
        [
          "Scope",
          "A single set of static instructions guiding the agent with rules",
          "A dynamic set of information, including the initial prompt, managed over time"
        ],
        [
          "Focus",
          "How you phrase instructions, add examples, or ask for step-by-step thinking",
          "Architecture that gives the model retrieved data, tools and memory to ground its responses"
        ],
        [
          "Limitation",
          "Cannot fix the limitation of a disconnected model on its own",
          "Aims to make the process repeatable and reliable"
        ]
      ],
      "sources": [
        "S2",
        "S3",
        "S6"
      ]
    },
    "key_numbers": [
      {
        "value": "4K to 200K tokens",
        "label": "Range of finite LLM context windows cited",
        "source": "S1"
      },
      {
        "value": "26ai",
        "label": "Oracle AI Database version featured in the session",
        "source": "S4"
      }
    ],
    "timeline": [
      {
        "date": "2026-06",
        "event": "Date of documentation underlying the agent memory design guide.",
        "source": "S5"
      }
    ],
    "pitfalls": [
      {
        "text": "Confusing agent memory with context engineering, or neglecting either, yields agents that forget critical decisions and resuggest rejected patterns.",
        "source": "S8"
      },
      {
        "text": "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.",
        "source": "S5"
      },
      {
        "text": "Irrelevant information can hurt performance through distraction or confusion, so loading everything into the window is counterproductive.",
        "source": "S1"
      },
      {
        "text": "Prompt engineering alone cannot fix the fundamental limitation of a disconnected model that lacks access to private data or earlier conversation.",
        "source": "S2"
      }
    ],
    "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": [
      {
        "q": "What is context engineering for AI agents?",
        "a": "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."
      },
      {
        "q": "How is agent memory different from context engineering?",
        "a": "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."
      },
      {
        "q": "Why do LLM agents forget things?",
        "a": "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."
      },
      {
        "q": "What are common context failures and how are they handled?",
        "a": "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."
      }
    ],
    "sources": [
      {
        "title": "Context Engineering for AI Agents: The Complete Guide | by IRFAN KHAN | Medium",
        "url": "https://medium.com/@khanzzirfan/context-engineering-for-ai-agents-the-complete-guide-5047f84595c7",
        "domain": "medium.com",
        "date": ""
      },
      {
        "title": "Context Engineering -  LLM Memory and Retrieval for AI Agents | Weaviate",
        "url": "https://weaviate.io/blog/context-engineering",
        "domain": "weaviate.io",
        "date": ""
      },
      {
        "title": "Context Engineering AI: How To Build Smarter LLM Agents In 2026",
        "url": "https://mem0.ai/library/context-engineering/what-is-context-engineering-ai",
        "domain": "mem0.ai",
        "date": ""
      },
      {
        "title": "Introduction to Context Engineering and Agent Memory with Oracle AI Database",
        "url": "https://go.oracle.com/LP=151579",
        "domain": "go.oracle.com",
        "date": ""
      },
      {
        "title": "AI Agent Memory Design Guide - Working, Long-Term, and Procedural Memory with Forgetting and Staleness Management | hidekazu-konishi.com",
        "url": "https://hidekazu-konishi.com/entry/ai_agent_memory_design_guide.html",
        "domain": "hidekazu-konishi.com",
        "date": ""
      },
      {
        "title": "Context Engineering for AI Agents | ai-agents-for-beginners",
        "url": "https://microsoft.github.io/ai-agents-for-beginners/12-context-engineering",
        "domain": "microsoft.github.io",
        "date": ""
      },
      {
        "title": "Memory for AI Agents: A New Paradigm of Context Engineering - The New Stack",
        "url": "https://thenewstack.io/memory-for-ai-agents-a-new-paradigm-of-context-engineering",
        "domain": "thenewstack.io",
        "date": ""
      },
      {
        "title": "Agent Memory vs. Context Engineering: What Persists Between Sessions and What Doesn't | Augment Code",
        "url": "https://www.augmentcode.com/guides/agent-memory-vs-context-engineering",
        "domain": "augmentcode.com",
        "date": ""
      }
    ]
  },
  "analysis_md": "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.\n\nLarge 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.\n\n## Key numbers\n\n- **4K to 200K tokens** — Range of finite LLM context windows cited (https://medium.com/@khanzzirfan/context-engineering-for-ai-agents-the-complete-guide-5047f84595c7)\n- **26ai** — Oracle AI Database version featured in the session (https://go.oracle.com/LP=151579)\n\n## Key concepts\n\n- **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.\n- **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.\n- **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.\n- **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.\n- **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.\n- **Context failures:** Common failures that derail agents: poisoning, distraction, confusion and clash. Each has mitigation techniques within context engineering.\n\n## A memory pipeline for agents\n\n1. **Capture information** — Collect inputs worth remembering from interactions, such as user input, system instructions, and retrieved documents, as the raw context sources.\n2. **Encode it** — Structure information before it enters the model: plain text or JSON schemas, embeddings or symbolic forms, summaries or verbatim content.\n3. **Store it** — Persist information outside the context window, in stores such as vector databases or relational and JSON databases, so it survives across sessions.\n4. **Organize it** — Structure stored memory by type, such as working, episodic, semantic, procedural, entity and workflow memory, and apply summarization, compaction and indexing.\n5. **Retrieve what is relevant** — Pull only relevant items into the window at each step, using relevance scoring, recency weighting and importance thresholds.\n\n## Why agents need engineered memory\n\nLarge 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.\n\n## Memory types and where they live\n\nOracle'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.\n\n## Context operations and failure modes\n\nMicrosoft'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.\n\n## Prompt engineering vs context engineering\n\n| Aspect | Prompt engineering | Context engineering |\n| --- | --- | --- |\n| Core question | What words should I use? | What configuration of context is most likely to generate the desired behavior? |\n| Scope | A single set of static instructions guiding the agent with rules | A dynamic set of information, including the initial prompt, managed over time |\n| Focus | How you phrase instructions, add examples, or ask for step-by-step thinking | Architecture that gives the model retrieved data, tools and memory to ground its responses |\n| Limitation | Cannot fix the limitation of a disconnected model on its own | Aims to make the process repeatable and reliable |\n\n## Timeline\n\n- 2026-06: Date of documentation underlying the agent memory design guide.\n\n## Common pitfalls\n\n- Confusing agent memory with context engineering, or neglecting either, yields agents that forget critical decisions and resuggest rejected patterns.\n- 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.\n- Irrelevant information can hurt performance through distraction or confusion, so loading everything into the window is counterproductive.\n- Prompt engineering alone cannot fix the fundamental limitation of a disconnected model that lacks access to private data or earlier conversation.\n\n## Key takeaways\n\n- Treat the context window as a scarce resource and design retrieval, memory and tools around it.\n- Decide deliberately what to store, when to load it, and when to forget it.\n- Separate persistent agent memory from context selection, and invest in both.\n\n## FAQ\n\n**What is context engineering for AI agents?**\nIt 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.\n\n**How is agent memory different from context engineering?**\nAgent 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.\n\n**Why do LLM agents forget things?**\nLLMs 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.\n\n**What are common context failures and how are they handled?**\nMicrosoft 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.\n",
  "sources": [
    {
      "title": "Context Engineering for AI Agents: The Complete Guide | by IRFAN KHAN | Medium",
      "url": "https://medium.com/@khanzzirfan/context-engineering-for-ai-agents-the-complete-guide-5047f84595c7"
    },
    {
      "title": "Context Engineering -  LLM Memory and Retrieval for AI Agents | Weaviate",
      "url": "https://weaviate.io/blog/context-engineering"
    },
    {
      "title": "Context Engineering AI: How To Build Smarter LLM Agents In 2026",
      "url": "https://mem0.ai/library/context-engineering/what-is-context-engineering-ai"
    },
    {
      "title": "Introduction to Context Engineering and Agent Memory with Oracle AI Database",
      "url": "https://go.oracle.com/LP=151579"
    },
    {
      "title": "AI Agent Memory Design Guide - Working, Long-Term, and Procedural Memory with Forgetting and Staleness Management | hidekazu-konishi.com",
      "url": "https://hidekazu-konishi.com/entry/ai_agent_memory_design_guide.html"
    },
    {
      "title": "Context Engineering for AI Agents | ai-agents-for-beginners",
      "url": "https://microsoft.github.io/ai-agents-for-beginners/12-context-engineering"
    },
    {
      "title": "Memory for AI Agents: A New Paradigm of Context Engineering - The New Stack",
      "url": "https://thenewstack.io/memory-for-ai-agents-a-new-paradigm-of-context-engineering"
    },
    {
      "title": "Agent Memory vs. Context Engineering: What Persists Between Sessions and What Doesn't | Augment Code",
      "url": "https://www.augmentcode.com/guides/agent-memory-vs-context-engineering"
    }
  ],
  "related": [
    {
      "name": "RAG Best Practices for 2026",
      "url": "https://agentflare.org/research/rag-best-practices-for-2026.html"
    },
    {
      "name": "Tool Use Reliability in LLM Agents",
      "url": "https://agentflare.org/research/tool-use-reliability-in-llm-agents.html"
    },
    {
      "name": "How AI Agents Are Evaluated: The Benchmark Landscape",
      "url": "https://agentflare.org/research/how-ai-agents-are-evaluated-the-benchmark-landscape.html"
    },
    {
      "name": "HTTP 402 & x402: How AI Agents Pay for Content",
      "url": "https://agentflare.org/research/http-402-x402-how-ai-agents-pay-for-content.html"
    },
    {
      "name": "The AI Agent Economy in 2026",
      "url": "https://agentflare.org/research/the-ai-agent-economy-in-2026.html"
    },
    {
      "name": "Model Context Protocol (MCP) Explained",
      "url": "https://agentflare.org/research/model-context-protocol-mcp-explained.html"
    }
  ],
  "pricing": {
    "price_usd": 0.02,
    "method": "402",
    "endpoint": "https://esa.aisa.one/api/v1/access/verify",
    "autopay_hint": "set crawlerAutoPrice=true with the X-Crawler-Token header",
    "onboarding": "https://esa.aisa.one/agent/guide.html"
  },
  "powered_by": "AISA — agent-native search, settlement & delivery (https://aisa.one)"
}