DEV Community

Cover image for AWS Strands - AgentCore Shorterm Memory Integration
Vimal Venugopal
Vimal Venugopal

Posted on

AWS Strands - AgentCore Shorterm Memory Integration

Prerequisites

Prior Knowledge of

  • Strands Agents
  • Python 3.1x
  • AWS Credentials with access to Bedrock and related components
  • Access to Anthropic Claude Haiku 4.5
  • AgentCore Short-term Memory with MemoryManager, AgentInitializedEvent and MessageAddedEvent hooks

We will use MemoryManager to store short term conversational history and retrieve n number of conversations
This is a simple AWS Strands agents that uses a web search tool to query and store the results.
Initialize agents with conversation history using session management
Can use this to help Migrate from MemoryClient to MemoryManager architecture

This example demonstrates Short Term Memory of AgentCore. Below is the high level architecture.

Architecture

Project Structure

ProjectStructure

STEP1: Requirements.txt - Packages Needed

Packages Needed

STEP2: Packages Installation

Packages Install

STEP3: Import all packages

Import

STEP4: Memory Manager Initialization(Memory_Manager.py)

Memory_Manager

STEP5: Memory SessionManager Initialization(Memory_Manager.py)

SessionManager

STEP6.1: MemoryHookProvider Initialization - Part 1
MemoryHookProvider

STEP6.2: MemoryHookProvider Initialization - Part 2
MemoryHookProvider

STEP7: Agent Tools Definition (Agent_Tools.py)
Agent Tools

STEP8: Agent Initialization (Personal_Agent.py)

Agent Initialization

Agent Initialization

AGENT Testing in Terminal

AGENT TESTING

AGENT TESTING-1

AGENT TESTING-2

AGENT TESTING-3

Top comments (0)