Showing posts with label System Design. Show all posts
Showing posts with label System Design. Show all posts

Wednesday, November 25, 2026

The Seven Types of AI Agent Memory

 


AI agent memory is a crucial aspect of context engineering - the practice of managing what information an AI model receives to make decisions. Simply storing data is not the same as enabling an agent to "remember" it effectively.

Working Memory

Contains immediate information (instructions, recent messages, tool results) that an AI model can process in real-time during a conversation (1:28). It serves as the model's current "short-term" context and is essential for maintaining coherence during an active session.

Key Components

Working memory typically includes the following elements sent as the current context:

·        System Instructions: High-level guidance on how the agent should behave.

·        Current User Request: The specific question or prompt just received.

·        Recent Message History: The flow of the conversation leading up to the current turn.

·        Selected Documents: Any retrieved files or external information relevant to the current task.

·        Latest Tool Results: Real-time data or outputs generated by tools the agent has accessed.

Limitations and Management

·        The Context Window: Every model has a fixed limit on the total amount of information it can read in a single call. Because we cannot send infinite data, systems must actively manage this memory.

  • Decision Making: To keep the interaction efficient, applications must decide what to keep, what to summarize, and what to remove as the conversation grows.
  • Trade-offs: Expanding the context window increases both cost and latency. Furthermore, overflowing the context with too much data can make it significantly more difficult for the model to isolate and identify the most important details

Semantic Memory

Stores long-term storage for stable facts, preferences, and knowledge that must persist across different conversations. Unlike working memory, which is limited by the context window and resets, semantic memory ensures an agent remembers key details without needing to reload entire chat histories.

Core Characteristics

  • Durable Information: It holds specific, semi-permanent records such as a user’s name, time zone, or preferred programming language.
  • Owner and Scope: Each piece of semantic memory is linked to an owner and a specific scope, defining where and for whom the agent can access that information.
  • Lifecycle Management: Because facts can change (e.g., switching from Python to TypeScript), systems must be able to update, replace, or delete stored facts as needed.

Implementation Best Practices

  • Selective Storage: Not every detail mentioned in a conversation should be saved. An application must filter to ensure only truly

Episodic Memory

Records specific past events or individual agent runs, focusing on the history of an interaction rather than just static facts. It is essential for an agent to "recall what happened" during a particular task, providing context for how to handle similar situations in the future.

Key Components

  • Goal and Context: The initial objective and the state when the task began.
  • Process: The specific steps the agent took to attempt the task.
  • Tool Interactions: Any external tools used and the data returned by those tools.
  • Results and Feedback: Any errors encountered, user feedback received, and the final outcome.

Why it Matters

While semantic memory tells an agent what true, episodic memory provides the narrative of what occurred. By storing these episodes, an agent can:

·        Improve Decision Making: When faced with a similar task later, the agent can retrieve the most relevant past episode to see what previously succeeded or failed.

·        Learn from Experience: It serves as a historical log that allows the system to analyze past behaviors and refine its future approach.

Procedural Memory

Preserves the rules, habits, and workflows the agent follows to perform specific tasks (e.g., "check documents before searching the web"). In AI agents it represents the methods, rules, and workflows that govern how an agent performs a specific task. Rather than focusing on user data or static facts, this type of memory acts as the "instruction manual" or "habit" the system follows to ensure consistency and safety in its operations.

Key aspects

·        Defining Rules & Steps: It establishes the standardized sequence of actions for a task. For example, a rule might dictate that the agent must search internal documents before checking the web.

·        Safety & Validation: It incorporates critical gatekeeping steps, such as validating a database query before execution or requiring human approval before performing high-impact actions like issuing a refund.

·        Implementation: These procedures are typically stored within the system instructions, tool descriptions, reusable skills, or the underlying workflow code of the application.

By codifying these behaviors, procedural memory ensures the agent operates in a predictable manner, regardless of the specific input it receives from a user.

External Memory

Information stored outside of the AI model's internal weights, such as in databases, document stores, email inboxes, or other external applications. Since models have limited internal knowledge, this memory provides a way for agents to access private, up-to-date, or vast amounts of specific data.

Retrieval-Augmented Generation (RAG) is a design technique that lets a model look facts from external memory and then populate it into working memory.

Parametric Memory

General knowledge embedded directly within the model's weights during training, providing basic language and reasoning capabilities. These weights are the learned parameters or internal settings that allow an AI to function as a general-purpose model.

Key characteristics

  • Innate Abilities: This memory enables the model to perform core tasks like understanding human language, writing code, or explaining common concepts without needing to access an external database.
  • Static Knowledge: Because this knowledge is baked into the model's weights during training, it does not update during a standard inference call.
  • Limitations: It is generally a poor choice for storing private, frequently changing, or highly specific facts. Because the information is fixed at the time of training, it may become outdated and lacks awareness of a user's private data unless the application explicitly provides it in the context 

Prospective Memory

The agent's ability to schedule and trigger future tasks, such as sending a follow-up email on a specific day. Because an AI agent is not constantly running, it cannot simply "wait" for a future date like a human might; it requires a specialized system to wake it up.

Core Components

  • Future Tasks & Triggers: The system must save a task along with a trigger, which could be a specific date, time, or set of conditions.
  • Context Preservation: To ensure the agent can resume work later, the task must store the necessary context, its current status (e.g., pending, in progress), and any approval requirements.
  • Reliable Scheduling: A scheduler is used to monitor these triggers and "wake" the application at the correct time. Upon waking, the application checks the latest situation to determine if the task should proceed or if circumstances have changed (e.g., the user replied in the meantime).
  • Workflow Safety: Since schedulers may retry, the system requires a clear status management mechanism to prevent the same action from being executed multiple times.


Example covering all seven types of memory

A customer named Rani inquiring about a late order: "My order is late. Can you tell me what happened?"

  1. External Memory: The system stores Rani’s order records, shipping status, and company policies outside the model. The agent retrieves the relevant order ID and policy status.
  2. Semantic Memory: The agent loads persistent facts, such as the company’s required communication tone and Rani's verified language preferences.
  3. Episodic Memory: If applicable, the agent retrieves a similar past delivery case to inform its response.
  4. Working Memory: Rani's email, the retrieved external facts, and the specific task instructions are bundled into the current context window for the model to process.
  5. Parametric Memory: The model uses its pre-trained linguistic knowledge to draft a friendly, helpful reply.
  6. Procedural Memory: The agent follows a defined workflow: check the order, check the policy, draft a reply, and wait for human approval.
  7. Prospective Memory: The agent schedules a future follow-up task for Friday. If Rani has not replied by then, a scheduler will wake the system to prepare a follow-up for approval.

Designers should not treat these as seven separate databases, but as seven distinct design responsibilities.

Note: AI is used to polish this article

Monday, October 5, 2026

The Evolution of AI Agent Development: From Prompting to Autonomous Systems

 


The evolution of AI agents follows a clear architectural progression. Early applications focused almost exclusively on crafting better prompts. Today's enterprise-grade agents rely on multiple engineering layers that progressively increase intelligence, reliability, and autonomy.

Each new layer addresses specific limitations exposed by the previous one.

Rather than thinking of AI as "better models," it is more useful to think of it as an evolving software stack. Models remain the reasoning engine. The surrounding architecture increasingly determines real-world performance.

Layer 1: Prompt Engineering

Teaching the AI how to think
Prompt engineering represents the first generation of AI application development. Here, intelligence is largely encoded in the instructions given to the model.

Instead of simply asking a question, developers define:

  • Roles
  • Objectives
  • Constraints
  • Output formats
  • Reasoning style
  • Examples

Example:
Instead of: "Answer customer questions."

Better: "You are a senior customer support specialist for an enterprise SaaS company. Answer politely, cite product documentation, never speculate, and escalate billing questions."

The prompt essentially becomes the agent's temporary personality and operating manual.

Common techniques:

  • Role prompting
  • Few-shot examples
  • Chain-of-thought prompting
  • Step-by-step reasoning
  • Structured outputs (JSON, XML)
  • System prompts
  • Prompt templates

Strengths:

  • Extremely fast to build
  • Little infrastructure required
  • Excellent for isolated tasks
  • Works well for chatbots and assistants

Limitations:
The model only knows what exists inside its context window. It cannot:

  • Retrieve fresh information
  • Remember previous work
  • Use enterprise systems
  • Access databases
  • Interact with software
  • Perform multi-step workflows

Prompt engineering reaches diminishing returns because no matter how sophisticated the prompt becomes, the model remains isolated.

Layer 2: Context Engineering

Teaching the AI what it needs to know

Once developers realized prompts alone were insufficient, focus shifted toward supplying better information rather than better instructions.

This gave rise to Context Engineering.

Instead of embedding every possible fact into a prompt, the agent dynamically gathers the information it needs before reasoning.

Think of the context window as the agent's working memory. Context engineering determines what information enters that memory.

Typical sources include:

  • Enterprise documents
  • Databases
  • CRM systems
  • APIs
  • Web search
  • Code repositories
  • Vector databases
  • Previous conversations

This is the foundation of Retrieval-Augmented Generation (RAG).

Instead of hallucinating, the agent retrieves.

Example:

A procurement agent receives: "Compare these vendors."

Instead of relying on training data, it automatically gathers:

  • Existing contracts
  • Vendor performance history
  • Pricing
  • Compliance reports
  • Risk assessments
  • External market data

Only after collecting this information does reasoning begin.

Context Engineering Components:

Information Retrieval

  • Semantic search
  • Keyword search
  • Hybrid search

Memory Management

  • Short-term memory
  • Conversation history
  • Long-term memory

Tool Calling

  • SQL databases
  • ERP systems
  • CRM platforms
  • Internal APIs

Filtering
Only relevant information is added. Irrelevant context wastes tokens and reduces reasoning quality.

Why Context Engineering Matters:
Better models help. Better context helps far more.

Many enterprise failures blamed on "weak AI" are actually failures in context engineering.

Layer 3: Harness Engineering

Teaching the AI how to execute work

As organizations attempted increasingly complex workflows, another limitation appeared.

Large projects quickly exceeded available context windows.

Imagine asking an agent: "Build an entire ERP implementation plan."

Eventually:

  • Earlier decisions disappear
  • Objectives are forgotten
  • Inconsistencies emerge
  • Duplicated work appears

This is known as "context leakage."

The solution is not a larger model. The solution is an external orchestration layer.

This is Harness Engineering.

What is the Harness?
The harness surrounds the LLM. Instead of the model managing everything internally, the harness manages:

  • Tasks
  • Checkpoints
  • Execution state
  • Memory
  • Retries
  • Tool usage
  • Workflow progression

The model becomes only one component inside a much larger software system.

Example Workflow:
Suppose an engineering agent is asked: "Upgrade a 200-service microservice platform."

The harness may:

  1. Analyze repositories
  2. Create dependency graph
  3. Prioritize services
  4. Generate migration plan
  5. Execute updates
  6. Run unit tests
  7. Run integration tests
  8. Review failures
  9. Retry failures
  10. Produce deployment plan

Each task becomes an independent execution unit. The harness stores results externally. The model never has to remember everything.

Responsibilities of the Harness:

  • Task decomposition
  • State persistence
  • Checkpoint management
  • Retry logic
  • Tool integration
  • Execution monitoring
  • Result aggregation

Why the Harness Matters:
Longer workflows become possible. Complex multi-step processes can be orchestrated. The model focuses on reasoning, not bookkeeping.

Layer 4: Loop Engineering

Teaching the AI how to improve itself
Loop engineering represents the next evolution. Instead of relying on human prompts for every stage, this involves creating self-guided scaffolding outside the harness layer.

This allows agents to autonomously trigger tasks, perform maintenance, fix bugs, and verify their own work without constant human intervention.

What Loop Engineering Enables:

  • Autonomous verification
  • Self-correction
  • Iterative improvement
  • Bug detection and fixing
  • Continuous optimization
  • Long-duration autonomy

Example:
An agent is tasked with "Migrate this data pipeline."

In loop engineering, the agent:

  1. Executes the migration
  2. Automatically verifies results
  3. Detects any anomalies
  4. Investigates root causes
  5. Fixes identified issues
  6. Re-verifies
  7. Documents the process
  8. Escalates only if unresolved

The system operates over hours or days without human intervention.

Key Components:

  • Evaluation frameworks
  • Feedback loops
  • Error detection
  • Self-correction mechanisms
  • Autonomy guardrails
  • Human escalation paths

Why Loop Engineering Matters:
Agents can operate independently over long durations. This enables truly autonomous systems that improve over time rather than simply executing once and stopping.

The Progression of Autonomy

Layer Focus Model Role Human Role Complexity
Prompt Engineering Instructions Execute single query Write prompts Low
Context Engineering Information Reason with rich data Manage data sources Medium
Harness Engineering Orchestration Reason and decide Design workflows High
Loop Engineering Learning Reason, decide, improve Monitor boundaries Very High

What This Means for Builders

If you're building Layer 1 systems: Focus on prompt craft and few-shot examples. Understand that you've hit the ceiling on what prompting alone can achieve.

If you're building Layer 2 systems: Focus on information retrieval and context quality. Better context solves more problems than better prompts.

If you're building Layer 3 systems: Focus on orchestration, task decomposition, and external state management. The model is now a component inside a larger system.

If you're building Layer 4 systems: Focus on evaluation frameworks, self-correction mechanisms, and safety boundaries. How does the system know it succeeded? How does it catch and fix its own errors? How do you prevent drift?

The Competitive Advantage

Most organizations are still in Layers 1 and 2. They're writing prompts and managing context.

The organizations building Layers 3 and 4 right now will have a 2-3 year head start on complex, autonomous systems.

The architecture you build today determines what's possible tomorrow.