Get startedGet started for free

Do agents remember?

1. Do agents remember?

Now that we have a working agent, a question arises: do agents remember? If we run the agent twice, does it recall what happened the first time?

2. Stateless vs. Memory

By default, most simple agents (including our AgentWorkflow so far) are stateless between runs. That means if we ask it one question now and another later, it doesn’t remember the earlier conversation or any info we gave it. Each interaction is a fresh start, as if meeting for the first time.

3. Memory matters

Human conversations, of course, are built on context: we remember what was said earlier. Similarly, more advanced AI applications often need to maintain context or memory across multiple exchanges to be truly helpful.

4. Introducing context

For example, if we tell an AI our name in one message, we’d like it to be remembered in later replies instead of asking again. In LlamaIndex, the key concept to maintain memory is the agent’s state or context. “Context” is like the agent’s notepad or memory bank where it can store information to recall later.

5. From stateless to context-enabled

By design, AgentWorkflow doesn’t automatically persist anything between runs, which is why it’s stateless by default. In other words, agents don’t inherently remember previous conversations unless we design them to. We’ll fix that by introducing a “context” to maintain state. This idea is important: an intelligent workflow might involve multiple runs or continuous interaction, so being able to carry information forward (like user preferences, names, or intermediate results) is key.

6. Let's practice!

We’ll see this in action in the next section.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.