The Easiest Way to Create Self-Improving AI Agents
By Arseny Shatokhin
Key Concepts
- Agentic Memory: AI agents retaining and utilizing past experiences and information.
- Short-Term Memory: Temporary storage of information (e.g., conversation history, tool call results).
- Long-Term Memory: Persistent storage of information, categorized into procedural, semantic, and episodic memory.
- Semantic Memory: Recalling facts and knowledge, implemented using retrieval-augmented generation (RAG) with vector databases.
- Background Approach: Traditional method of updating agent knowledge by processing data in the background (e.g., after handling a large number of customer support tickets).
- Agentic Approach: Novel method where the agent autonomously decides when to update its memory based on interactions and experiences.
- Self-Improvement: Agents learning from their mistakes and improving performance over time.
- Personalization: Tailoring agent responses and actions based on user-specific information and preferences.
- Vector Database: A database that stores data as vectors, enabling semantic search and retrieval of similar information.
- MZero: An open-source platform for building memory layers for AI agents.
- Agencies Form: An agent framework used in the tutorial.
- Shared State: A feature in Agencies Form that allows sharing variables between agents and tools.
Agentic Memory: Overview and Types
The video begins by highlighting the evolution of AI agents towards human-like capabilities, including reasoning and task completion. A key limitation is their lack of memory, which prevents them from learning from past experiences. The video then introduces the concept of agentic memory, drawing parallels to human memory systems.
- Human Memory Analogy: Human memory is divided into short-term and long-term memory. Short-term memory holds temporary information, while long-term memory stores information for extended periods.
- AI Agent Memory Mapping: The paper "Cognitive Architectures for Language Agents" maps these memory types to AI agent components.
- Short-Term Memory: Corresponds to conversation history, tool call results, and the attention layer of the underlying LLM.
- Long-Term Memory: Broken down into procedural (how to perform tasks, system prompt), episodic (recalling past events, few-shot prompting), and semantic memory (recalling facts).
- Semantic Memory and RAG: Semantic memory in agents is analogous to semantic search using a vector database, also known as retrieval-augmented generation (RAG).
Building Semantic Memory: Approaches
The video outlines two primary approaches to building semantic memory in AI agents:
- Standard Background Approach: Data is processed in the background and added to the agent's knowledge base (vector database) periodically. Example: Extracting key details from customer support tickets after a certain volume is reached.
- Novel Agentic Approach: The agent autonomously determines when to update its memory based on its interactions and experiences. This approach is highlighted as more natural and powerful, enabling the agent to learn from almost every message and tool call.
Benefits of Agentic Memory
The video emphasizes that the primary benefit of agentic memory is self-improvement, not just context retrieval.
- Self-Improvement through Memory: Agents can remember their own mistakes and avoid repeating them. This is achieved by adding tools that allow the agent to read, update, and delete memory.
- Personalization: Agentic memory enables personalization, giving agents a competitive edge. Agents that remember user preferences and history become more valuable and harder to replace. Example: ChatGPT's ability to draft emails based on remembered user information.
Implementing Memory: Options
Three options for implementing memory in AI agents are presented:
- Vector Database (DIY): Using a vector database like Pinecone or V8 to build a custom memory layer from scratch. This provides the most control but requires more development effort.
- Framework with Built-in Memory: Utilizing built-in memory features in agentic frameworks like CrewAI or Langchain. This is easy to start with but can become limiting in production due to lack of control.
- Specialized Memory Layer Platform: Using a dedicated platform like MZero, which provides a balance between control and development effort. The video highlights MZero as a preferred option due to its open-source nature and generous free tier.
Practical Tutorial: Building an Agent with MZero
The video provides a step-by-step tutorial on building a customer support agent with memory using MZero and the Agencies Form framework.
- Setting up the Environment:
- Creating a GitHub repository and cloning it locally.
- Opening the repository in Cursor IDE.
- Copying the
cursor_rules.txtfile to inform Cursor about the Agencies Form framework. - Creating a Python virtual environment.
- Generating Agents with Cursor:
- Using Cursor's composer agent mode to generate the customer support agent and its tools.
- Providing a detailed prompt describing the agent's role, context, and tool functionalities.
- Including documentation for the MZero API in the prompt to guide Cursor in generating accurate code.
- Testing and Refining Tools:
- Using Cursor to test the generated tools and identify errors.
- Iteratively correcting the code based on test results and MZero API documentation.
- Adjusting the
requirements.txtfile to include the correct MZero package version.
- Implementing User-Specific Memory:
- Utilizing MZero's
user_idparameter to store and retrieve memories specific to each user. - Using Agencies Form's shared state feature to manage the
user_idacross agents and tools. - Modifying the tools to access the
user_idfrom the shared state.
- Utilizing MZero's
- Crafting Instructions:
- Writing detailed instructions for the agent, including its role, context, and workflow.
- Instructing the agent to check memory before responding to users and to save relevant information, such as customer details and encountered errors.
- Specifying what information the agent needs to save in memory, including customer name, email, phone number, and order history.
- Instructing the agent to remember errors encountered when using tools, such as the
make_refundtool.
- Running the Agent and Demonstrating Memory:
- Running the agent and demonstrating its ability to remember user information and past errors.
- Showing how the agent avoids repeating mistakes by recalling previous interactions and tool outcomes.
- Example: The agent remembers that dairy products are non-refundable and avoids attempting to process a refund for them in subsequent interactions.
Example Scenario: Customer Support Agent
The tutorial uses a customer support agent as a practical example. The agent has tools to:
- Read memory
- Update memory
- Delete memory
- Make a refund
The agent is designed to learn user preferences and avoid repeating errors. The make_refund tool is intentionally designed to fail for certain items (e.g., dairy products) to demonstrate the agent's ability to learn from its mistakes.
Key Arguments and Perspectives
- Agentic memory is crucial for creating self-improving AI agents. By remembering their mistakes, agents can avoid repeating them and improve their performance over time.
- Personalization is a key benefit of agentic memory. Agents that remember user preferences and history become more valuable and harder to replace.
- The agentic approach to memory is more natural and powerful than the traditional background approach. It allows agents to learn from almost every interaction and tool call.
- Using a specialized memory layer platform like MZero provides a good balance between control and development effort.
Notable Quotes
- "Memory is the easiest way for you to create self-improvement proving AI agents because agents can literally remember their own mistakes."
- "Personalization gives your agents a very unique Competitive Edge because if your agent knows everything about your client or your users it is instantly more valuable for them."
Technical Terms and Concepts
- LLM (Large Language Model): The underlying AI model that powers the agent.
- RAG (Retrieval-Augmented Generation): A technique for improving the accuracy and relevance of LLM responses by retrieving information from an external knowledge source.
- Vector Database: A database that stores data as vectors, enabling semantic search and retrieval of similar information.
- API (Application Programming Interface): A set of rules and specifications that allow different software systems to communicate with each other.
- Cursor: An AI-powered code editor used in the tutorial.
- Agencies Form: An agent framework used in the tutorial.
- Shared State: A feature in Agencies Form that allows sharing variables between agents and tools.
Logical Connections
The video progresses logically from introducing the concept of agentic memory to explaining its benefits and then providing a practical tutorial on how to implement it. The tutorial builds upon the concepts introduced earlier, demonstrating how to use MZero and Agencies Form to create a customer support agent that can learn from its mistakes and personalize its responses.
Synthesis/Conclusion
The video effectively argues that agentic memory is a crucial component for building truly intelligent and useful AI agents. By enabling agents to remember past experiences and learn from their mistakes, agentic memory unlocks the potential for self-improvement and personalization. The practical tutorial provides a clear and actionable guide for implementing agentic memory using MZero and Agencies Form, empowering developers to create more sophisticated and effective AI agents. The key takeaway is that memory is not just about storing information; it's about enabling agents to learn, adapt, and improve over time, ultimately leading to more valuable and personalized user experiences.
Chat with this Video
AI-PoweredLoad the transcript when you're ready to chat so the initial page stays lighter.
Related Videos

Why Does This Guy Appear In Kids Videos?
sphynx

TIC en las Organizaciones - Electiva Complementaria II Unisimon
Julieth Güell S

How to Tame Your Advice Monster | Michael Bungay Stanier | TED
TED

Margaret Heffernan: Why it's time to forget the pecking order at work
TED

The importance of psychological safety: Amy Edmondson
The King's Fund

What Is Psychological Safety?
Harvard Business Review

13-Conflict Management: Listening in Conflict
Deliberate Development