AI agents can be enhanced with memory through three advanced patterns: (1) Callbacks automatically update memory during conversation by intercepting the agent's lifecycle to add custom logic before or after model/tool calls, enabling context tracking without increasing agent complexity; (2) Custom Tools enable structured memory storage by creating tools to read and write user profiles or preferences as dictionary objects in a database, allowing agents to proactively recall information like dietary restrictions across sessions; (3) Multimodal Memory extends memory beyond text to include photos, videos, and audio files, allowing agents to connect dots across different media types from past interactions. These patterns transform agents from simple conversational tools into intelligent assistants with comprehensive memory capabilities.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Your AI agent still has no memory? Fix it with these 3 patternsAdded:
In our previous video, you showed us three ways of making agents smarter by adding memory to them. Yeah, we've talked about first session [music] state and second multi-agent state and last persistent memory. But you teased that there are three more ways of giving agents memory.
>> Yeah, that's right. And let me show you.
Welcome back to the show, Annie. Uh what's your story here at Google?
Thanks, Martin. You know, I spent years as a software engineer here, but I realized that my real passion is AI education. So now I'm over on the developer side helping developers building AI agents.
Yeah, you've been deep in the world of agents, right? Yeah, and I noticed the pattern. Everyone thinks AI intelligence is just about the model and tooling.
They're forgetting the other important piece, that is memory. Guilty. I'm definitely focused on the model first when I'm building AI apps. Yeah, most people do. But if you want to build an app that actually impresses people, you need an agent that use a full brain. And here we have six patterns for adding agent memory.
>> [snorts] >> And in our previous video, we talked about the first three. Yeah, that's right. And let's talk about the last three and when you should use them.
I've also built a codelab for this so that you can try it out yourself.
Okay, I will add a link to your codelab, Annie, in and our last video in the description below. Let's dive in.
>> Sure.
All right, let's talk about callbacks.
You know, sometimes you need to update memory automatically based on the conversation. You want a spy that watches and takes notes. A spy? That sounds [clears throat] mysterious.
What's an example? Oh, let's see. We want our trip planning app to nudge the user to new types of sites. And here, the user asked for a museum.
So, if the user asked for another museum, the app suggests a different type of attraction instead. So, there's no duplicated activities that planned by the agent. I see. So, it's like having a dedicated assistant who's constantly updating their notebook while you talk.
>> Yeah, that's right. And here is how to implement it. So, whenever an agent runs, you can add your own custom logic before or after the agent runs, before or after the model is called, and before or after any tools are called. And this callback intercepts the life cycle of the agent.
And this is great for saving context about the conversation without making the agent itself more complex. Got it.
And what does the code look like? Yeah, here is the after tool callback.
So, here we set the activity type to cultural, food, or outdoor, depending on what tool was called.
And here, uh we write that activity type to the tool context.
And over here, in the planner instructions, we read the last activities.
If it was cultural, the museum expert is banned.
And the agent build its own context simply by doing its job. Nice. All right, let's talk about custom tools.
You know, so far, memories have been unstructured text. It can be a lot of data for the agent to dig through.
But if the agent needs to know that you're vegan, let's put that in a user profile. So, it's moving from unstructured chat logs to structured data. Yeah, exactly. So, if you tell the agent that you're vegan, it doesn't just remember that was said. It proactively updates a dietary preference field in your profile. Okay, and what would the user experience be here? Sure. So, here I'm asking the agent to plan dinner for me.
It doesn't know my preferences, so it asks me.
So, I tell the agent I'm vegan.
And now I restart the script.
Again, I asked it to plan dinner for me.
And now it knows that I'm vegan, so it doesn't ask. Instead, it just suggests a vegan restaurant for me. That looks useful. How did you implement that, Annie? Sure. I gave it two new tools.
The first tool is save user preference, and the second tool is recall user preferences.
And in the agent instructions, I tell the agent to call recall user preferences first.
And here I tell it to call save user preferences whenever the user states a preference.
And then the save user preferences takes a dictionary object of preferences as an input parameter.
And it then saves that dictionary as a new record in the database.
So, this recall user preferences tool just read that record back. Very good. I can see how having structured data can come in handy. What's next on your list?
Yeah. So, the last pattern is multimodal memory. You know, all our saved memories have been text so far, but humans remember more than text. Right. We remember the vibe of a photo or the sound of a voice or the feeling of a video, right? Yeah, exactly. So, a good agent should remember those things, too.
And in this example, I've uploaded picture, a video, and an audio file with a travel assistant agent.
And then I will ask, "Based on the picture, video, and audio I shared with you, where should I travel?" So the agent then reply based on my preferences.
And it's connected the dots across different media types from the past.
That's right. Here's a code that puts a session with a picture, video, or audio into the memory bank.
And you can see here are memories in the memory bank.
And here I give the agent the preload memory tool so that it can use to load a memory from the memory bank into the conversation. Excellent, Annie.
I knew how to implement session memory before, but I haven't actually seen the code for the other patterns.
Uh could you give us a quick recap, please? Sure, Martin. So firstly, we talked about how to use callbacks to update memory automatically without adding complexity to the agent. And secondly, we talked about how to use custom tools to read and write structured data like user profiles. And lastly, we talked about how to use multimodal memory to remember photos, videos, audios with what has AI agent engine memory bank. That's a great list.
Uh thank you for sharing this with us, Annie. Yeah, thank you for having me, Martin. And thank you, everyone, for watching. If you have any questions for Annie or me, please let us know in the comments.
Also, do let me know what you thought of today's episode.
I read every single comment.
Until next time.
>> [music]
Related Videos
OpenHuman VS Hermes AI: Who Wins?
JulianGoldieSEO
285 views•2026-05-29
Long-Running Agents — Build an Agent That Never Forgets with Google ADK
suryakunju
142 views•2026-05-30
This computer is made from real human brain cells. And you can buy it.
Talktmsmedia
3K views•2026-05-28
BREAKING: Microsoft’s New Image Generating Model Beat Out GPT 1.5 and Nano Banana 2
aimmediahouse
122 views•2026-06-03
I Made the Same Anime Fight Scene in Every AI Video Generator
NobleGooseAnime
295 views•2026-05-30
Nvidia Bets Big On AI PCs | New Chip To Power Windows Laptops | Technology | AI Updates | N18S
cnnnews18
3K views•2026-06-01
I Tested NEW Opus 4.8 on Four Projects (Updated LLM Leaderboard)
AICodingDaily
298 views•2026-05-29
3D Platformer Update - NO CAPES
SolarLune
294 views•2026-05-30











