0:05 Welcome back to real terms for AI. In today's journey on our agent and agentic path, we'll be talking about memory and agents. You mean state? Well, yes. Memory and agents is a lot like managing state in an app. So, we're done. I'm glad that you think we could be, but no. Since you're so clearly talkative about this, how about you walk us through the beginnings of it? That's what I wanted to do. Let's talk all about memory. Just like us, there are many different types of memory you pair with different agent components, both for features, functionality, and to get to the outcome that you want. We'll cover some of the top ones here, starting with working memory. You can think of working memory just like a piece of scratch paper you might have when you're completing multiple tasks together where you're managing some sort
0:51 of storage in order to store incremental states in order to compute the next state that you need to move to. This is kind of like how you could write down different lines of a long algebra or calculus problem ultimately to find the answer. Another type of memory is short-term memory. This is the context of an existing session or conversation that the agents or agents are part of. Short-term memory is information that is relevant about the session that the agent may need to know. And long-term memory is another type. These are things that we may need to compute during or even after the session is over or after the agent is done. These are typically attributes about one of the agents about say something that happened in the session that we should remember for the future. And there are many other types of memory that you may read about out there which can be applied to specific agent scenarios or specific workflows.
1:37 Let's walk through how you could implement each of these types of memories for an agent-based system. First, for working memory, this could be as simple as storing a response or an output the agent is using to complete the task. You could store it in memory or throw it in a variable. Depends on the size. Next, short-term memory could be stored in a session using something like memory store. The thing here is we want to be able to recall that context very quickly and continue passing it along in the session to subsequent steps to provide as much information as possible in order to answer a question. the most accurately. We may want to store, for example, rag results in short-term memory that we can then use in future tasks with those different values. However, we may also want to consider how we can delete information here because let's say we have the wrong answer in one of our rag results. We
2:24 don't want our agent to overweight to that information. So, let's delete it so we don't use that moving forward. And last, long-term memory is almost like its own system. You might pass in long-term attributes to an agent at the start of a session. Things like, hey, this is what I know about the user or I always need to address X when I'm building this type of code. But collecting long-term memory is very much like our brain does. Is this a sort of brain dump? We need to take all of the working and short-term memory and then provide some level of summarization to provide the key points. Then we store this, not all that long session data that may have generated those attributes. Long-term attributes become very important over time where, for example, in a coding agent, you have things that are always corrected. You could use a long-term attribute to remind the agent at the outset of the task instead of having to recomputee
3:10 that correction again every time, which gets expensive. And just like we talked with a conversational agent, you'll use these concepts if you have systems with multiple agents. Agents need to communicate with each other using things like a common session, but agents might also have their own session information depending on the sorts of tasks they're performing. You might also choose to use some data privacy rules to keep certain data within a particular agent, say a credit card number, and then pass around the deidentified information to subsequent tasks and agents instead. You can find more about this in our discussions about data privacy from our first season of Real Terms with AI. So I think we covered many state concepts here and each of these patterns can map to things that you might already do in application development. So it's not really that different after all except
3:55 for marshalling. Like I said, not that different from building applications after all. Remember how much we need to marshall data types and formats between apps and systems. Try not to. Yeah. No, definitely lost plenty of time doing that. Uh you can find out more about LLM memory in the links below with a few guides to get going. for myself and Aza. As always, happy prompting. [Music]