Day 54: Giving an LLM Long-Term Memory with DynamoDB

Dev.to AI
Generative AI

One of the biggest limitations of stateless serverless applications using LLMs (like Amazon Bedrock or OpenAI) is amnesia. Every API call starts from zero. Today, I built a persistent memory engine for my AI Financial Agent so it remembers a user's behavior from previous months. The Architecture: I created a DynamoDB table with user_id (from Cognito JWT) as the Partition Key and month_year as the Sort Key. Before calling Bedrock, my Python Lambda fetches last month's summary: def get_user_memory(user_id, prev_month_str): # DynamoDB get_item logic.