← All videos >THE FULL PICTURE
Take the AI agents course

ai agents / agent memory / persistent memory

Simple Memory: How AI Agents Remember Between Runs

Course walkthrough

AI Agents from Scratch

Lesson 9 of 12

All lessons in this series

  1. 1I'll Teach You How To Build AI Agents From Scratch (10 Billion Tokens Proof)
  2. 2What Is An AI Agent? (ChatGPT Doesn't Count)
  3. 3The ONE Trick That Turns ChatGPT Into An AI Agent (Tools)
  4. 4The ReAct Loop: How Cursor & Claude Code Actually Work
  5. 5The System Prompt That Changes Everything (Prompt Engineering For AI Agents)
  6. 6How To Make Your AI Agent Truly Autonomous (Without It Going Rogue)
  7. 7How To Trigger An AI Agent (5 Different Ways)
  8. 8Subagents Explained: How AI Agents Launch Other AI Agents
  9. 9Simple Memory: How AI Agents Remember Between Runs
  10. 10How AI Agents Actually Remember (Memory + RAG Explained)
  11. 11How To Actually Tell If Your AI Agent Is Good (Evaluation)
  12. 12The Complete Guide To Building AI Agents (10 Lesson Recap)

Your AI agent is smart — but the second it finishes running, it forgets everything.

In this video, I break down the simplest ways to give your AI agent persistent memory — from a basic file dump all the way to database-backed storage.

You'll learn: → Why AI agents lose context between runs (and why it matters) → Strategy 1: Raw dump — copy the full conversation into a file → Strategy 2: LLM summarization — compress what matters → Strategy 3: Specialized files — portfolios.txt, backtest_results.txt → Strategy 4: Database storage — queryable, structured, scalable → Why none of these work for 100-page documents (that's next)

If you're prepping for an AI-native systems design interview, this is non-negotiable.

#AIAgents #MachineLearning #ArtificialIntelligence #SoftwareEngineering

Transcript

0:05Welcome back to the course on how to build your own AI agent from scratch Here's what we've accomplished so far The first thing we talked about was ChatGPT and then we talked about the problems with ChatGPT it being

0:20unable to execute actions or know things in real time We introduced tools which are ways for ChatGPT to actually do things on our

0:32behalf We also introduced the orchestration loop and ways so the agent can execute things automatically or with user approval This includes a toggle

0:45switching the automation modes or even something like a whitelist of approved tools Finally we talked about how do you start or trigger an AI agent whether that's a manual start via API call via a webhook

1:00or a scheduled job And we talked about sub agents how sub agents are specialized AI agents that are triggered from a parent agent They tend to have

1:12a different set of tools a different system prompt with different instructions that make it specialized for a specific task Now we're going to talk about one of the most important decisions

1:26you have to make for your AI agent Right now it's an art not a science This thing is called memory Now let's turn our attention to the screen We have this

1:41AI agent I'm on the OpenAI Playground and I just have this you are a helpful assistant message I'm going to type into the chat what is my name I already gave

1:53it my name so it should know my name It says your name is Austin This is good Now let's refresh the page and start from scratch Let's go back to you

2:05are a helpful assistant and I'm going to say what is my name If I say this the AI doesn't know It doesn't have any memory

2:21So let's say after this agent runs let's go to a completed agent as a prime example After the agent runs we're going to

2:32take all of this information and literally just copy paste it into a file And so the next time the agent runs it's going

2:44to have a tool The tool is going to first query memories first read this file It's going to know what it did last time and then it's going to repeat so

2:57that it already knows what it did before This is a simple way of implementing memory and it works for some basic use cases but there are a number of issues For

3:10one all of this stuff is not really relevant A long conversation being prepended to the beginning of a conversation that's not super helpful

3:23and it's expensive Language models charge you per token So if you have all this information having stuff it doesn't need then you're getting charged for no reason and the worst performance

3:35You might just need the list of portfolios you've created before You might not need all the other information So the next part of having memory isn't just a raw dump but

3:47just having an LLM take the entire conversation summarizing all the parts that you need and then just putting that in a file Maybe you just need this This is one file

4:01and every time an agent runs it's just going to append information to this one file This is actually a fairly decent way of implementing memory naively

4:13You can have different smarter strategies Maybe you'll have this file which is just the list of portfolios it's created And then maybe another file that's a list of backtest results And

4:26the AI agent has tools to know which files it should query into the context window That's another strategy That's something AI tools should be able to help you with Like Cursor and Claude Code do all the time It

4:40reads the files from the system when it needs them That's another great way of implementing memory You also don't need to just store it in files You can store all of this

4:53in a database You might want to index the text fields maybe have some categories to make it easy to query but you want to store the information somewhere Well it can be queried by the AI agent This is

5:08the easiest lowest lift way of implementing memory And with modern day LLMs it works pretty good but it doesn't work all the time

5:21Sometimes you might have entire documents hundreds of pages and you need your language model to find the information within those documents And you can't just dump a hundred pages into the

5:35context window That's gonna be way too expensive So what you can do instead is store it in a vector database I'll explain that

5:47in the next video This is critical If you're trying to do an AI native systems design interview this is very important Stick around

6:00and see you in the next video

Join the conversation

Loading conversation…