05 Agentic Systems 3 min read 638 words

Agent Memory and State (Dec 2025)

Memory is what allows an agent to learn and maintain context over time. In late 2025, agent memory has evolved from simple "Chat History" to a Multi-Tiered Cognitive Architecture that includes persistent episodic and semantic layers.

memorystateagentspersonalizationcore
01hierarchy

The Memory Hierarchy

Agents use a tiered approach to storage:

TierTypeTechnologyPurpose
L1Working MemoryContext Window / KV CacheCurrent task steps, local vars
L2Episodic MemoryVector DB / Graph"What did I do last time?"
L3Semantic MemorySQL / Knowledge GraphUser preferences, "The Truth"
02reasoning trace

Short-Term: The Reasoning Trace

In 2025, we no longer just store the "Messages." we store the State Object.

  • The Scratchpad: A dedicated section of the prompt where the agent "writes notes" to itself that are NOT shown to the user.
  • KV Cache Tiling: For long-running agents, we use Prefix Caching to keep the "System Instruction" and "Standard Tools" warm in GPU memory, only swapping the dynamic task state.
03past experiences

Episodic Memory: Past Experiences

Episodic memory stores "Runs" or "Trajectories."

  • If an agent failed to scrape a website last Tuesday, episodic memory should prevent it from trying the same failing selector today.
  • Pattern: When a task completes, summarize the "Lessons Learned" and store them in a vector DB. At the start of a new task, perform a Self-Search for similar previous tasks.
04memory persona

Semantic Memory: The Persona

Semantic memory stores "Facts" about the user or the environment.

  • "The user prefers JSON output."
  • "The production DB is offline between 3 AM and 4 AM."

2025 Best Practice: Use a Knowledge Graph for semantic memory. Unlike vector search (which is fuzzy), a graph provides deterministic retrieval of entities and relationships (e.g., User -- OWNER_OF --> Project_A).

05agentic personalization

Mem0 and Agentic Personalization

In late 2025, Mem0 (and similar frameworks) has become the standard for "Smart Memory."

  • It automatically extracts "User Insights" from conversations.
  • It provides a "Memory API" that agents can call to remember or forget specific triplets of information.
  • Impact: Agents feel "Alive" because they remember a detail you mentioned 3 months ago in a different session.
06questions

Interview Questions

Q: How do you handle "Conflicting Memories" in an agentic system?

Strong answer: Conflicting memories (e.g., the user said "I like blue" last week but says "I like red" now) are handled via Temporal Weighting or Explicit Disputing. In my architecture, I assign a timestamp and a confidence_score to every memory triplet. If a new fact conflicts with an old one, the agent is prompted to "Resolve the Conflict" by asking the user for clarification or defaulting to the most recent timestamp. We also use Decay Functions where older, non-reinforced memories are eventually pruned from the active index.

Q: Why is the "Context Window" alone insufficient for a staff-level Agent architecture?

Strong answer: First, Cost and Latency: Filling 1M tokens of context for every turn is prohibitively expensive even with context caching. Second, Signal-to-Noise: Large context windows suffer from "In-context Learning" degradation—the model gets distracted by irrelevant historical turns. A Staff-level architecture uses Selective Memory Retrieval (RAG over history) to only pull in the 3-5 most relevant historical interactions, keeping the Reasoning Engine focused on the current sub-goal.

07references

References

  • Mem0. "The Memory Layer for AI Agents" (2024/2025)
  • Park et al. "Generative Agents: Interactive Simulacra of Human Behavior" (2023)
  • LlamaIndex. "Managed Index for Agentic Memory" (2025)

Next: Planning and Decomposition

summary · added by this rebuild

Key takeaways

01

Memory splits into three tiers

L1 working memory in the context window and KV cache, L2 episodic memory of past runs in a vector DB or graph, L3 semantic memory of durable facts.

02

Episodic memory stops repeated mistakes

Summarising lessons learned when a task completes, then self-searching for similar past runs at the start, is what stops an agent retrying the selector that failed last week.

03

Graphs beat vectors for stable facts

Semantic memory wants deterministic lookup of entities and relationships — User OWNER_OF Project_A — rather than the fuzzy nearest-neighbour match a vector index returns.

04

Conflicts resolve on timestamp and confidence

Every memory triplet carries a timestamp and confidence score; a contradiction either prompts the user or defaults to the newest fact, with decay pruning unreinforced entries.

05

A bigger window is not memory

Filling a million tokens each turn is expensive and degrades attention, so selective retrieval of the three to five most relevant past interactions keeps reasoning focused.