Back to Blog
What is Agentic Memory? Types of Memory, State, and Storage Formats in AI Agents
agentic-aiai-agentsmemory-systemsllmpythonbeginners-guide

What is Agentic Memory? Types of Memory, State, and Storage Formats in AI Agents

A beginner-friendly guide to agentic memory: understanding state vs. memory, short-term vs. long-term memory, episodic, semantic, and procedural types, and how they are stored in production.

If you have ever spent an evening experimenting with ChatGPT, Claude, or an open-source AI agent, you have likely noticed a frustrating paradox.

During a single session, the AI can feel remarkably smart. It can write code, debug complex logic, plan a travel itinerary, and summarize dense documents. But as soon as you close the tab and start a new conversation tomorrow, it suffers from total amnesia. It has no idea who you are, what programming language you prefer, what mistakes it made yesterday, or what projects you are actively building together.

Every single conversation is Day Zero.

In the AI research world, this is known as the "Goldfish Problem"—standard Large Language Models (LLMs) are completely stateless. They process your prompt, predict the next tokens, send back an answer, and immediately wipe their mental slate clean.

To transform a stateless language model into a truly capable autonomous AI agent, we must give it an external, persistent brain. We call this Agentic Memory.

In this guide, we will break down what agentic memory actually is, demystify the crucial difference between State and Memory, explore the core types of memory (Short-Term, Long-Term, Episodic, Semantic, and Procedural), and see how they are stored and retrieved in real-world AI applications.


1. What is Agentic Memory? (And Why LLMs Don't Have It)

To understand agentic memory, we first need to understand how large language models actually work under the hood.

A raw language model has two distinct ways of knowing things:

  1. Training Data (Parametric Weights): This is the vast ocean of books, websites, and code that the model read during training. It knows that Paris is the capital of France or how to write a binary search algorithm in Python. However, this knowledge is frozen in time. The model cannot update its neural network weights while chatting with you.
  2. The Prompt Context Window (In-Context Working Memory): When you chat with an AI, the chat interface secretly copies your recent conversation messages and pastes them into every new prompt. This gives the illusion of memory. But context windows have strict token limits, get slower and more expensive as conversations grow, and disappear completely the moment your session ends.

Agentic Memory is the external software system and database layer that wraps around an AI agent, allowing it to record, store, retrieve, and update information across steps, tasks, sessions, and time.

Think of it like a computer:

  • The LLM is the CPU (it performs the thinking and reasoning).
  • The Context Window is the RAM (it holds what the agent is looking at right now).
  • Agentic Memory is the Hard Drive / SSD (it permanently saves files, user preferences, and historical logs so they are never lost).

2. State vs. Memory: The Crucial Difference

One of the most common confusions for beginners building AI agents is mixing up State and Memory. While they sound similar, they serve two completely different purposes in an agent's lifecycle.

Figure 1: Agent State vs. Agent MemoryFigure 1: Agent State vs. Agent Memory

What is Agent State? (Ephemeral)

State is what the agent is doing and thinking right now, during the active execution of a single task.

It tracks:

  • The current step in a workflow (e.g., "Step 2 of 5: Fetching user records").
  • Temporary variables and parameters extracted during the task (e.g., budget = 80000, category = "laptop").
  • The active chain-of-thought scratchpad and recent tool outputs.

The defining characteristic of State is that it is temporary (ephemeral). Once the agent finishes the task or crashes, its state is typically cleared.

What is Agent Memory? (Persistent)

Memory is information that is saved to persistent storage so the agent can recall it in future tasks and future sessions.

It tracks:

  • User profile preferences (e.g., "User prefers TypeScript over Python").
  • Past experiences and lessons learned (e.g., "Last week, deploying to AWS failed because of an IAM permission error").
  • Reusable skills and workflows (e.g., "Here is the standard 6-step checklist to deploy our app").
DimensionAgent StateAgent Memory
Primary Question"What am I doing right now?""What have I learned that matters for the future?"
LifespanMinutes to hours (Current run only)Days, months, or years (Across sessions)
Where It LivesIn-memory variables, execution stack, RedisRelational DBs, Vector DBs, Knowledge Graphs
Disappears When?The task finishes or the server restartsNever (unless explicitly deleted or pruned)
AnalogySticky notes on your desk while workingA personal notebook or diary kept on a shelf

3. The Complete Taxonomy of Agentic Memory

How should we categorize agentic memory?

The easiest and most useful mental model separates memory into two dimensions:

  1. Memory Lifetime (How long does it last?): Short-Term vs. Long-Term.
  2. Information Type (What kind of information is it?): Episodic, Semantic, or Procedural.

Figure 2: The Complete Taxonomy of Agentic Memory in AIFigure 2: The Complete Taxonomy of Agentic Memory in AI

Here is how these categories connect:

  • Short-Term Memory represents the temporary, session-scoped working context.
  • Long-Term Memory represents the persistent store, which is further divided into:
    • Episodic Memory: Events & experiences ("What happened?")
    • Semantic Memory: Facts & world knowledge ("What is true?")
    • Procedural Memory: Skills, workflows & rules ("How to perform tasks?")

Let us examine each of these memory types in detail.


4. Deep Dive: The Core Types of Agent Memory

4.1 Short-Term / Working Memory (The Scratchpad)

What it stores: The immediate context and working notes of the ongoing task.

When an AI agent is working on a multi-step objective—such as "Analyze our database and generate a financial report"—it needs a scratchpad where it can write down intermediate clues, track sub-tasks, and store tool outputs.

Example Payload:

  • Typical Storage: In-memory Python dictionaries, Redis, or framework state stores (such as LangGraph checkpointers).
  • Lifespan: Minutes to hours. Usually scoped to a single task execution.

4.2 Long-Term Memory (The Persistent Knowledge Base)

What it stores: Any piece of valuable information that should survive across sessions and days.

Instead of keeping everything in the prompt (which quickly overflows the model's context window and costs money), long-term memory selectively extracts important facts and saves them to a permanent database.

Example Payload:

  • Typical Storage: PostgreSQL with pgvector, Pinecone, Qdrant, MongoDB, or Weaviate.
  • Lifespan: Days to years.

4.3 Episodic Memory ("What Happened?")

What it stores: Events, interactions, and experiences that took place in previous agent runs.

Think of episodic memory as the agent's autobiographical diary. It is fundamentally chronological and narrative-driven.

Why is this so powerful?

Imagine an engineer instructs an agent: "Deploy our API service to AWS."

During the deployment, the agent hits an unexpected error:

  1. It builds the Docker container.
  2. It pushes to Amazon ECR.
  3. The deployment fails because the IAM task execution role is missing permissions to pull secrets.
  4. The user adds the missing IAM policy, and the deployment succeeds.

If the agent has Episodic Memory, it saves this entire episode:

Next week, when you ask the agent to deploy a second microservice, it checks its episodic memory:

"Last time we deployed a service to ECS, the task failed because the IAM role lacked Secrets Manager access. I'll verify the IAM policy before starting the deployment to save time."

By recalling past episodes, the agent learns from its mistakes instead of repeating them indefinitely.

  • Typical Storage: SQL or Document databases (for structured queries) combined with Vector Databases (for semantic search over past summaries).
  • Lifespan: Long-term.

4.4 Semantic Memory ("What is True?")

What it stores: Facts, concepts, and relationships about the world, the user, and the project.

While Episodic Memory is about events that happened at a specific time, Semantic Memory is about timeless facts stripped of event context.

  • Episodic Memory: "On Tuesday morning, Souvik told me he doesn't like using raw SQL strings in code."
  • Semantic Memory: "Souvik uses Prisma ORM or Drizzle for all database queries."

Semantic memory generally takes one of two primary formats:

Format A: Document / Vector Format

A natural language statement paired with a vector embedding for fuzzy similarity search:

Format B: Knowledge Graph / Triples Format

Representing facts as connected entities using Subject →\to Predicate →\to Object relationships:

  • [Project Alpha] →uses\xrightarrow{\text{uses}} [Next.js 15]
  • [Project Alpha] →database\xrightarrow{\text{database}} [PostgreSQL]
  • [Project Alpha] →deployed_on\xrightarrow{\text{deployed\_on}} [AWS Fargate]

This graph structure allows the agent to make multi-hop connections that simple keyword search cannot match: "Find the database used by the project deployed on AWS Fargate."

  • Typical Storage: Vector databases (Pinecone, Qdrant) or Knowledge Graphs (Neo4j, Mem0).
  • Lifespan: Long-term.

4.5 Procedural Memory ("How to Do Things?")

What it stores: Skills, workflows, routines, and rules.

Procedural memory is the agent's equivalent of human muscle memory. When you ride a bicycle or tie your shoelaces, you don't stop to reason through every muscle twitch. You simply execute a practiced procedure.

For an AI agent, procedural memory is action-oriented. It tells the agent how to accomplish a goal.

Examples of Procedural Memory Formats:

1. Standard Operating Procedure (SOP) / Workflow:

2. Agent Skill Files:

In modern agent harnesses (like Claude Code, Antigravity, or Codex), procedural memory is often stored as markdown or YAML Skill Files:

3. Executable Code / Functions:

In advanced systems, procedural memory can be stored directly as executable Python or TypeScript functions. The agent retrieves the verified script from its tool library and runs it directly, without needing to spend thousands of tokens generating the code from scratch each time.

  • Typical Storage: YAML/JSON files, Markdown skill folders, Git repositories, or workflow engines.
  • Lifespan: Long-term, version-controlled, and continuously refined.

5. Summary Table: The 5 Memory Types at a Glance

Here is the easiest reference sheet to remember the differences between each memory type:

Memory TypeCore QuestionWhat It StoresTypical FormatTypical Storage EngineLifespan
Short-Term (Working)"What am I doing right now?"Current conversation, active task variables, scratchpadMessages JSON, task state dictIn-Memory RAM, Redis, LangGraph checkpointerMinutes →\to Hours
Long-Term"What should survive across sessions?"Accumulated user knowledge, guidelines, preferencesJSON document + Vector embeddingPostgreSQL (pgvector), Pinecone, QdrantDays →\to Years
Episodic"What happened?"Past experiences, event logs, past execution errorsEpisode JSON + natural language summaryRelational DB (SQL) + Vector DatabaseLong-term
Semantic"What is true?"Facts, concepts, entity relationships, preferencesFact strings, vector chunks, Graph triplesVector DBs, Neo4j Knowledge GraphLong-term
Procedural"How do I do this?"Workflows, skills, SOPs, tool policies, codeWorkflow JSON, Markdown skills, Python codeFile system, Git repos, workflow enginesLong-term & Versioned

6. How and Where Agent Memory is Stored in Production

One of the most practical questions developers ask is: "What database should I actually use to store these memories?"

A common architectural trap is assuming that all agent memory belongs in a single Vector Database. In reality, modern agent systems use purpose-built storage tiers tailored to each memory type's access pattern.

Figure 3: How Agent Memory Types are Stored in ProductionFigure 3: How Agent Memory Types are Stored in Production

1. Short-Term Memory Storage: RAM & Fast Caches

  • Technologies: In-memory Python objects, Redis, Memcached, LangGraph Checkpoint stores.
  • Why: Short-term working state requires ultra-low latency (<5ms< 5\text{ms}) reads and writes on every turn of a conversation. Redis is ideal because it supports key expiration (TTL), automatically cleaning up abandoned sessions after 24 hours.

2. Episodic Memory Storage: Hybrid SQL + Vectors

  • Technologies: PostgreSQL + pgvector, SQLite, MongoDB Atlas.
  • Why: You need structured SQL columns to filter by metadata (e.g., WHERE user_id = '123' AND outcome = 'failed'), paired with vector embeddings to find experiences semantically similar to your current task.

3. Semantic Memory Storage: Vector Databases & Knowledge Graphs

  • Technologies: Pinecone, Qdrant, Milvus, Weaviate, Neo4j, Mem0.
  • Why: Semantic facts need similarity search ("What are the user's styling preferences?"). For complex relational knowledge (e.g., "Which team owns the database connected to the billing service?"), a Knowledge Graph maps the connections cleanly.

4. Procedural Memory Storage: Version-Controlled Files

  • Technologies: Git repositories, Markdown skill files, YAML workflows, AWS Step Functions.
  • Why: Procedural skills are essentially code. Storing them in version-controlled repositories allows engineering teams to audit, test, update, and roll back agent skills just like standard software.

7. How All Memory Types Work Together: A Real-World Walkthrough

To see how these memory systems orchestrate in harmony, let us trace a real-world scenario from start to finish.

Imagine you give an AI engineering agent a prompt:

User: "Deploy my Next.js portfolio application to our staging server."

Here is what happens behind the scenes:

Figure 4: How Agent Memory Types Work Together During a TaskFigure 4: How Agent Memory Types Work Together During a Task

  1. Working Memory (Short-Term): The agent creates an active state session. It tracks: current_task = "deploy_app", environment = "staging", status = "in_progress".
  2. Procedural Memory: The agent looks up its skill catalog and retrieves the Deployment Workflow procedure: Step 1 (Run tests) →\to Step 2 (Build Docker container) →\to Step 3 (Deploy) →\to Step 4 (Run health check).
  3. Semantic Memory: The agent queries its knowledge base to find out what technology stack this specific app uses: "Uses Next.js 15, deployed on AWS Fargate, environment variables located in AWS Secrets Manager".
  4. Episodic Memory: Before running the build, the agent queries its past experiences: "Have we had issues deploying this project before?" It retrieves an episode from last week: "Build failed because the optional sharp image package was missing from package.json". The agent automatically checks for sharp before proceeding, avoiding a repeat failure!
  5. Execution & Write-Back: The agent executes the deployment successfully. Finally, it logs a new episode into Episodic Memory: "Deployed commit 8f921a to staging in 42 seconds with zero errors".

This seamless loop of Working State →\to Procedural Rules →\to Semantic Facts →\to Episodic Lessons →\to Execution is what separates a naive chatbot from an autonomous agent.


8. A Beginner-Friendly Python Implementation

Let us look at a clean, readable Python implementation demonstrating how these memory types work in code.

You do not need complex third-party frameworks to see the core mechanism in action. Here is a self-contained, runnable example:

What Happens When You Run This Code:

  1. The agent consults Semantic Memory to know that the project uses PostgreSQL.
  2. It checks Episodic Memory and recalls a past failure ("Ensure memory limit is at least 1024MB to avoid OOM").
  3. It loads the exact 4-step checklist from Procedural Memory.
  4. It completes the deployment and saves the new experience back to Episodic Memory.

9. Key Takeaways

  1. LLMs are Stateless by Design: A language model has no natural memory of previous conversations. Building intelligent agents requires an external memory system.
  2. State is Short-Term, Memory is Long-Term: State is the active scratchpad of the current task; memory is the persistent knowledge base that survives across sessions.
  3. The 3 Key Information Types:
    • Episodic Memory: Remembers events and experiences ("What happened?").
    • Semantic Memory: Remembers facts and concepts ("What is true?").
    • Procedural Memory: Remembers skills, workflows, and code ("How to do it?").
  4. Use the Right Database for the Job: Short-term state belongs in Redis or RAM; episodic logs belong in SQL + vector search; semantic facts belong in vector databases or knowledge graphs; procedural skills belong in version-controlled files.
  5. Memory Powers Autonomy: When an agent can learn from past mistakes, retain user preferences, and execute standardized procedures, it evolves from an interesting novelty into an indispensable engineering partner.

Related Posts

Beyond Naive RAG: Advanced, Hybrid & Agentic Retrieval

Beyond Naive RAG: Advanced, Hybrid & Agentic Retrieval

A comprehensive masterclass on enterprise RAG architectures, multi-query expansion, HyDE, hybrid search with RRF, ColBERT late interaction, Cross-Encoder reranking, GraphRAG, and self-correcting agentic loops

ragaivector-search+3 more
Read More
Complete Guide to Chunking Strategies for RAG

Complete Guide to Chunking Strategies for RAG

A complete guide to RAG chunking strategies, trade-offs, and Python implementations

ragaivector-search+1 more
Read More

“You have a right to perform your prescribed duty, but you are not entitled to the fruits of actions.”

— Bhagavad Gita