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.
Project Structure
STEP1: Requirements.txt - Packages Needed
STEP2: Packages Installation
STEP3: Import all packages
STEP4: Memory Manager Initialization(Memory_Manager.py)
STEP5: Memory SessionManager Initialization(Memory_Manager.py)
STEP6.1: MemoryHookProvider Initialization - Part 1

STEP6.2: MemoryHookProvider Initialization - Part 2

STEP7: Agent Tools Definition (Agent_Tools.py)

STEP8: Agent Initialization (Personal_Agent.py)
AGENT Testing in Terminal
*Using Streamlit we can display the same history in Web App
*

Summary
This tutorial showed how to build a personal agent using both MemorySessionManager and MemorySession.
You've learned:
MemorySessionManager: High-level manager for memory operations across multiple sessions
MemorySession: Session-specific interface that eliminates repetitive parameter passing. Using MemorySession removes the need to pass actor_id/session_id to every method
Type Safety: Session is bound to specific actor/session at creation time
Better Encapsulation: Session-specific operations are contained within the session object
Memory Hooks: Agent hooks can work with the session-based architecture
Conversation Continuity: Maintaining short-term memory functionality with MemoryManager & MemorySession
Key Benefits of MemorySession:
Simplified API: No need to pass actor_id/session_id to every method call
Pre-configured Context: Session is bound to specific actor/session at creation
Consistent Interface: All session operations use the same pre-configured context













Top comments (0)