Amazon Bedrock AgentCore - Memory | Amazon Web Services

Amazon Web Services · Intermediate ·☁️ DevOps & Cloud ·10mo ago

Key Takeaways

Configures AgentCore Memory for short-term and long-term context using the AgentCore SDK

Full Transcript

Hello everyone. As part of the Amazon Bedrock agent core video series, we are going to cover agent core memory. As part of this video, so let's start with a simple scenario that describes the problem that we are trying to solve. Imagine you are talking to a tech support agent about an issue with your computer. You spend around 30 minutes explaining your problem. The agent suggests some workarounds and then you hang up. A week later, you call back the agent again because none of the solution worked. But here is the problem. Because the agent is stateless, it has completely forgotten everything you discussed previously. So you have to start over again explaining the same issue all over again. This is exactly what memory aims to solve. It provides a mechanism to store and retrieve relevant agent experiences during runtime creating a personalization layer between agents and the users. So let's go back to our tech support example. So when you first call in the agent suggests workarounds and stores the entire interactions in the memory. Now when you call back the next time hey none of those workarounds actually worked the memory system kicks in. It provides the agent the context of your previous conversation what was tried before what did not work and what kind of solutions were suggested. Now the agent can pivot intelligently saying so I see those previous workarounds didn't help. Let's try something different this time. So this gives us a several key benefits. First, the context retention across sessions. The agent remembers your history. Second, the improved decision quality over time. It learns what worked and what did not. Third, reduced processing and latency. No need to research the same solution repeatedly. Finally, the personalization at scale. The agent learns about each user individually. So we can split the memory into two broad categories. First is short-term memory. This is essentially a collection of raw events like user messages or tool calls and assistant responses. It also handles session management and conversation branching. Think of it like you have the ability to go back and edit the previous message and create a new conversation branch. The short-term memory gets updated accordingly. So for example, you looking for flight tickets from Atlanta to New York and then you change your mind to change the destination to New Jersey. So memory gets updated accordingly based on the new edits. So that is short-term memory. The second category is the long-term memory which extracts meaningful and actionable information from those raw events. For example, if you keep asking your agent to generate code in camel case, it might learn that as a user preference. Or if you buy a grand latte at Starbucks three times a week, it extracts I buy coffee three times a week as a semantic fact. While I like grande becomes a user preference. At a very high level, here is how it works. Like know user interactions first goes into the short-term memory storage. Then an offline workflow extracts meaningful information based on specified strategies whether that's user preferences or semantic facts or session summaries. Finally, a consolidation phase manages these memories over time, dduplicating, merging or updating information to maintain accuracy. So, memory transforms AI agents from stateless tools into intelligent assistant that learns and adapt over time, making every interaction more personalized and effective. So, with this, we'll go into the code walkthrough in the demo. First import the memory client from the bedrock agent core. Then define the memory name. Then create memory using memory client by passing the memory name uh description event expiry date which defines the TTL like know time to live. In this case it's 7 days and the poll interval which checks the status in regular interval. In this case it's for every 10 seconds. You can see that the memory got created in the console. Next, we create the langraph agent. This function creates a langraph based fitness coach agent that integrates with agent core memory for conversation persistence. It sets up a chat bedrock lm with clots on it. defines the list events tool for retrieving conversation history and builds a graph for flow that automatically saves user assistant exchanges to memory while providing personalized fitness guidance based on remembered context. Then we define the actor ID and the session ID. These ids ensure each conversation session is uniquely tracked in the memory system allowing the agent to maintain separate conversation history for different users and workout sessions. Then we do couple of interactions with the workout routine. All these conversations are getting saved in the short-term memory. Next, we will test the short-term memory retrieval functionality by creating a new agent instance using the same actor ID and the session ID. This demonstrates like no session continuity. When we ask about the previous interaction, the agent successfully retrieves the conversation history from the memory and provides contextually relevant responses based on the earlier exchanges. Next, we will go through the long-term memory. First we will define the memory name. Then let's create a memory using the memory client by passing the memory name, description, event expiry date, the poll interval. The main difference here is we also pass the strategy and the name space. As I mentioned earlier, there are three kinds of strategies. The user preferences, semantic facts or the session summaries. The name spaces the memory system uses an hierarchical structure similar to S3 storage like know where extracted information is organized under the specific path using runtime variables like um actor ID, the strategy ID or the session ID ensuring like know complete data separation between users and preventing information leakages across different user sessions. Then we define the actor ID, the session ID and the name space. These three IDs ensure each conversation session is uniquely tracked in the memory system allowing the agent to maintain separate conversation histories for different users and work sessions. Here we are just mocking up some previous conversations and adding all those to the short-term memory. This one adds everything to the short-term memory. when we list all the events it displays all the previous mocked up conversations. So behind the scenes you know you know after the create event call is done the memory system detects that the memory has the user preference strategy configured. So without any additional coding, the system analyzes the conversation for the preference indicators, identifies the statements like like uh I am a vegetarian and I really enjoy Italian cuisines and extract these preferences into structured data. The extracted preferences are saved in the configured name space. This automatic process ensures that important information is preserved in the long-term memory even after the short-term memory conversation records expires. Now when you try to retrieve the content like foot preferences from the memory, you can see the context and the user preferences. So when you ask for the restaurant recommendations in your wine based on the user preferences, it was able to provide the appropriate restaurant suggestions in your wine. So that's the end of this code walkthrough of agent code memory. Thanks.

Original Description

Episode 5 of 8-part series on Amazon Bedrock AgentCore - Memory In this video, you’ll explore AgentCore Memory, the service that enables your agents to remember both short‑term and long‑term context, so they can deliver personalized and coherent interactions across sessions. You’ll see: How to create and manage memory resources using the AgentCore SDK, including setting up short‑term memory for in-session context and long‑term memory for semantic facts and user preferences. A code walkthrough showing how to use MemoryClient to create memories, store conversation events, load previous interactions, and apply strategies like semantic memory, session summaries, or user preference extraction. How memory events are automatically logged and metrics like latency, invocation count, spans, and error metrics are emitted to CloudWatch for observability and debugging. Subscribe to AWS: https://go.aws/subscribe Sign up for AWS: https://go.aws/signup AWS free tier: https://go.aws/free Explore more: https://go.aws/more Contact AWS: https://go.aws/contact Next steps: Explore on AWS in Analyst Research: https://go.aws/reports Discover, deploy, and manage software that runs on AWS: https://go.aws/marketplace Join the AWS Partner Network: https://go.aws/partners Learn more on how Amazon builds and operates software: https://go.aws/library Do you have technical AWS questions? Ask the community of experts on AWS re:Post: https://go.aws/3lPaoPb Why AWS? Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud. Millions of customers—including the fastest-growing startups, largest enterprises, and leading government agencies—use AWS to be more agile, lower costs, and innovate faster. #AWS #AmazonWebServices #CloudComputing
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Amazon Web Services · Amazon Web Services · 0 of 60

← Previous Next →
1 Agentic AI Design Patterns Introduction and walkthrough | Amazon Web Services
Agentic AI Design Patterns Introduction and walkthrough | Amazon Web Services
Amazon Web Services
2 Galileo on modernizing on banking infrastructure | Amazon Web Services
Galileo on modernizing on banking infrastructure | Amazon Web Services
Amazon Web Services
3 Alliander Speeds Innovation and Energy Transition Using AWS | Amazon Web Services
Alliander Speeds Innovation and Energy Transition Using AWS | Amazon Web Services
Amazon Web Services
4 AWS and Scuderia Ferrari HP streamline F1 power unit assembly | Amazon Web Services
AWS and Scuderia Ferrari HP streamline F1 power unit assembly | Amazon Web Services
Amazon Web Services
5 How AWS machine learning supports Scuderia Ferrari HP pit stops | Amazon Web Services
How AWS machine learning supports Scuderia Ferrari HP pit stops | Amazon Web Services
Amazon Web Services
6 Nasdaq Builds Market Infrastructure of the Future with AWS | Amazon Web Services
Nasdaq Builds Market Infrastructure of the Future with AWS | Amazon Web Services
Amazon Web Services
7 AWS Security Hub Exposure Findings | Amazon Web Services
AWS Security Hub Exposure Findings | Amazon Web Services
Amazon Web Services
8 How do I use Session Manager port forwarding to connect to my EC2 instance through RDP?
How do I use Session Manager port forwarding to connect to my EC2 instance through RDP?
Amazon Web Services
9 How do I extend an EBS volume with LVM partitions?
How do I extend an EBS volume with LVM partitions?
Amazon Web Services
10 AWS Graviton makes it easy to optimize performance, cost, and sustainability | Amazon Web Services
AWS Graviton makes it easy to optimize performance, cost, and sustainability | Amazon Web Services
Amazon Web Services
11 Run Cloud Adoption Framework workshops with Miro | Amazon Web Services
Run Cloud Adoption Framework workshops with Miro | Amazon Web Services
Amazon Web Services
12 Getting Started with AWS Cost Optimization Hub | Amazon Web Services
Getting Started with AWS Cost Optimization Hub | Amazon Web Services
Amazon Web Services
13 Why did my Amazon SQS messages get sent to a dead-letter queue?
Why did my Amazon SQS messages get sent to a dead-letter queue?
Amazon Web Services
14 Declarative Policies for EC2 | Amazon Web Services
Declarative Policies for EC2 | Amazon Web Services
Amazon Web Services
15 How do I troubleshoot IAM permission issues for the Billing and Cost Management console?
How do I troubleshoot IAM permission issues for the Billing and Cost Management console?
Amazon Web Services
16 Integrity at Scale: Inside the Flo Health Mission | Amazon Web Services
Integrity at Scale: Inside the Flo Health Mission | Amazon Web Services
Amazon Web Services
17 Fueling Success: Small shifts, powerful performance | Amazon Web Services
Fueling Success: Small shifts, powerful performance | Amazon Web Services
Amazon Web Services
18 WEX enhances customer experience with AI-powered chatbot | Amazon Web Services
WEX enhances customer experience with AI-powered chatbot | Amazon Web Services
Amazon Web Services
19 Accelerate troubleshooting with Amazon CloudWatch investigations | Amazon Web Services
Accelerate troubleshooting with Amazon CloudWatch investigations | Amazon Web Services
Amazon Web Services
20 Why is my Windows WorkSpace stuck in the starting, rebooting, or stopping status?
Why is my Windows WorkSpace stuck in the starting, rebooting, or stopping status?
Amazon Web Services
21 Telemetry Pipelines for AI | Amazon Web Services
Telemetry Pipelines for AI | Amazon Web Services
Amazon Web Services
22 Getting Control over Security and Observability Data | Amazon Web Services
Getting Control over Security and Observability Data | Amazon Web Services
Amazon Web Services
23 The Problem with Telemetry Data Volume | Amazon Web Services
The Problem with Telemetry Data Volume | Amazon Web Services
Amazon Web Services
24 Telemetry Pipelines on AWS | Amazon Web Services
Telemetry Pipelines on AWS | Amazon Web Services
Amazon Web Services
25 What are Telemetry Pipelines? | Amazon Web Services
What are Telemetry Pipelines? | Amazon Web Services
Amazon Web Services
26 Using AI for RegEx on Telemetry Pipelines | Amazon Web Services
Using AI for RegEx on Telemetry Pipelines | Amazon Web Services
Amazon Web Services
27 Multi-Session Support in the AWS Console | Amazon Web Services
Multi-Session Support in the AWS Console | Amazon Web Services
Amazon Web Services
28 How CloudHedge delivers assessment with AWS ISV Tooling Program at no cost?
How CloudHedge delivers assessment with AWS ISV Tooling Program at no cost?
Amazon Web Services
29 How customers speed up migration and modernization to AWS with CloudHedge | Amazon Web Services
How customers speed up migration and modernization to AWS with CloudHedge | Amazon Web Services
Amazon Web Services
30 Chaos Experiment with Amazon ElastiCache | Amazon Web Services
Chaos Experiment with Amazon ElastiCache | Amazon Web Services
Amazon Web Services
31 Amazon S3 Access Points: Easily manage access for shared datasets on S3 | Amazon Web Services
Amazon S3 Access Points: Easily manage access for shared datasets on S3 | Amazon Web Services
Amazon Web Services
32 ElastiCache Valkey 8.0 - Savings and Efficiency | Amazon Web Services
ElastiCache Valkey 8.0 - Savings and Efficiency | Amazon Web Services
Amazon Web Services
33 Pennymac scales document processing with AWS | Amazon Web Services
Pennymac scales document processing with AWS | Amazon Web Services
Amazon Web Services
34 AWS | Next Level Innovation | Amazon Web Services
AWS | Next Level Innovation | Amazon Web Services
Amazon Web Services
35 Driving Cloud Innovation: Mindtickle's Partnership with AWS Enterprise Support | Amazon Web Services
Driving Cloud Innovation: Mindtickle's Partnership with AWS Enterprise Support | Amazon Web Services
Amazon Web Services
36 A Leader's Edge from Executive Insights | Amazon Web Services
A Leader's Edge from Executive Insights | Amazon Web Services
Amazon Web Services
37 How do I create a custom Amazon WorkSpaces image?
How do I create a custom Amazon WorkSpaces image?
Amazon Web Services
38 Charles Leclerc tests his AI-generated race track | Amazon Web Services
Charles Leclerc tests his AI-generated race track | Amazon Web Services
Amazon Web Services
39 Redington Scales India’s Cloud Access with AWS Partnership | Amazon Web Services
Redington Scales India’s Cloud Access with AWS Partnership | Amazon Web Services
Amazon Web Services
40 How do I prevent the resources in my CloudFormation stack from getting deleted or updated?
How do I prevent the resources in my CloudFormation stack from getting deleted or updated?
Amazon Web Services
41 How do I troubleshoot authentication errors when I use RDP to connect to an EC2 Windows instance?
How do I troubleshoot authentication errors when I use RDP to connect to an EC2 Windows instance?
Amazon Web Services
42 Exploring the Possibilities of Digital Twin & AI at the Edge | Amazon Web Services
Exploring the Possibilities of Digital Twin & AI at the Edge | Amazon Web Services
Amazon Web Services
43 Exploring the Possibilities of Digital Twin & AI at the Edge | Amazon Web Services
Exploring the Possibilities of Digital Twin & AI at the Edge | Amazon Web Services
Amazon Web Services
44 AWS at the FORMULA 1 AWS GRAN PREMIO DELL'EMILIA-ROMAGNA 2025 | Amazon Web Services
AWS at the FORMULA 1 AWS GRAN PREMIO DELL'EMILIA-ROMAGNA 2025 | Amazon Web Services
Amazon Web Services
45 What's new in RCPs | Amazon Web Services
What's new in RCPs | Amazon Web Services
Amazon Web Services
46 API Caching using Amazon ElastiCache | Amazon Web Services
API Caching using Amazon ElastiCache | Amazon Web Services
Amazon Web Services
47 Pendula: Amazon Nova Customer Testimonial | Amazon Web Services
Pendula: Amazon Nova Customer Testimonial | Amazon Web Services
Amazon Web Services
48 InDebted : Amazon Nova Customer Testimonial | Amazon Web Services
InDebted : Amazon Nova Customer Testimonial | Amazon Web Services
Amazon Web Services
49 Amazon DynamoDB global tables with multi-Region strong consistency | Amazon Web Services
Amazon DynamoDB global tables with multi-Region strong consistency | Amazon Web Services
Amazon Web Services
50 Siemens Mobility uses AWS to operate securely, efficiently on a global scale | Amazon Web Services
Siemens Mobility uses AWS to operate securely, efficiently on a global scale | Amazon Web Services
Amazon Web Services
51 How do I reuse a knowledge base session in Amazon Bedrock?
How do I reuse a knowledge base session in Amazon Bedrock?
Amazon Web Services
52 EP5: MBZUAI, CMU : Causal AI, Answering The “Why“ and “What if“ Questions | AWS for AI Podcast
EP5: MBZUAI, CMU : Causal AI, Answering The “Why“ and “What if“ Questions | AWS for AI Podcast
Amazon Web Services
53 Hema scales time to market developing a data mesh on AWS (Technical) - Cloud Adventures
Hema scales time to market developing a data mesh on AWS (Technical) - Cloud Adventures
Amazon Web Services
54 Hema scales time to market developing a data mesh on AWS (Business) - Cloud Adventures
Hema scales time to market developing a data mesh on AWS (Business) - Cloud Adventures
Amazon Web Services
55 How Langfuse Scaled Their AI Platform with AWS: From Open-Source to Enterprise | Amazon Web Services
How Langfuse Scaled Their AI Platform with AWS: From Open-Source to Enterprise | Amazon Web Services
Amazon Web Services
56 SLMs and LLMs: What’s the Difference? | Amazon Web Services
SLMs and LLMs: What’s the Difference? | Amazon Web Services
Amazon Web Services
57 SLMs and LLMs: When to use them? | Amazon Web Services
SLMs and LLMs: When to use them? | Amazon Web Services
Amazon Web Services
58 SLMs on CPU | Amazon Web Services
SLMs on CPU | Amazon Web Services
Amazon Web Services
59 Intelligent Model Routing | Amazon Web Services
Intelligent Model Routing | Amazon Web Services
Amazon Web Services
60 SLMs, LLMs, and Model Routing in Agents | Amazon Web Services
SLMs, LLMs, and Model Routing in Agents | Amazon Web Services
Amazon Web Services

Related Reads

📰
Terraform Cloudflare DNS Checklist Before Every Apply
Learn a checklist to ensure correct Terraform Cloudflare DNS configuration before applying changes to prevent potential downtime
Dev.to · Oleksandr Kuryzhev
📰
Building a Windows Laptop Monitoring Agent with Webex and Email Alerts
Learn to build a Windows laptop monitoring agent with Webex and email alerts for real-time notifications
Dev.to · sam codex
📰
What Is Infrastructure as Code? A Beginner's Guide
Learn the basics of Infrastructure as Code (IaC) and how to manage servers and cloud resources with code
Dev.to · Muskan Bandta
📰
I just released SKTR, a deterministic architecture review CLI
Learn about SKTR, a deterministic architecture review CLI for reviewing Git changes and how to use it to improve code quality
Dev.to · Pablo Rubianes 🇺🇾
Up next
AWS, Azure, GCP: The One Thing Every Business Gets Wrong
AI Daily
Watch →