Learn how to configure the User Memory feature to help your AI assistants automatically learn and remember information about users across chat sessions, providing increasingly personalized interactions.
What You'll Accomplish
Section titled “What You'll Accomplish”By the end of this guide, you will:
- Enable User Memory at the site level
- Configure memory strategies (preferences and semantic)
- Customize memory retrieval limits
- Override memory settings per chat app
- Understand how memory is stored and retrieved
Prerequisites
Section titled “Prerequisites”- A running Pika installation
- Access to
pika-config.tsfor site-level configuration - Basic understanding of your chat app structure
- AWS environment with Bedrock Agent Core Memory available
Understanding User Memory
Section titled “Understanding User Memory”User Memory automatically captures and stores information about users during conversations, then retrieves relevant context in future sessions.
What Gets Remembered
Section titled “What Gets Remembered”Preferences Strategy (enabled by default):
- Communication styles and format preferences
- Tool and workflow preferences
- Accessibility needs
- Stated likes, dislikes, and working methods
Semantic Strategy (enabled by default):
- Professional role and industry context
- Technical expertise level
- Project and domain knowledge
- Organizational context
How It Works
Section titled “How It Works”- During Conversations: The system identifies memorable information from user messages
- Storage: Insights are securely stored in AWS Bedrock Agent Core Memory with user-specific isolation
- Retrieval: When users start new conversations, relevant memories are retrieved and injected into prompts
- Updates: Memory is updated as new information becomes available
Step 1: Enable at Site Level
Section titled “Step 1: Enable at Site Level”Configure User Memory in your pika-config.ts file to enable it across all chat apps.
Location: apps/pika-chat/pika-config.ts
export const pikaConfig: PikaConfig = { // ... other configuration siteFeatures: { userMemory: { enabled: true, maxMemoryRecordsPerPrompt: 25, // Maximum total memories per prompt maxKMatchesPerStrategy: 10 // Maximum memories per strategy } }};Configuration Options
Section titled “Configuration Options”| Property | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable/disable user memory collection and retrieval |
maxMemoryRecordsPerPrompt | number | 25 | Maximum total memory results to include in a single prompt |
maxKMatchesPerStrategy | number | 10 | Maximum memories to retrieve per strategy (preferences, semantic) |
Step 2: Understand Default Strategies
Section titled “Step 2: Understand Default Strategies”When you enable User Memory, both preferences and semantic strategies are automatically enabled by default.
Why These Defaults?
Section titled “Why These Defaults?”Preferences Strategy:
- Users benefit immediately from personalized interaction styles
- Communication preferences are maintained across sessions
- No need to repeat formatting or accessibility needs
Semantic Strategy:
- AI understands user context and expertise level
- Responses are appropriately scoped from first interaction
- Domain knowledge builds over time
Step 3: Adjust Retrieval Limits (Optional)
Section titled “Step 3: Adjust Retrieval Limits (Optional)”Customize how many memories are included in each prompt based on your use case.
Conservative Configuration (Faster Responses)
Section titled “Conservative Configuration (Faster Responses)”siteFeatures: { userMemory: { enabled: true, maxMemoryRecordsPerPrompt: 15, // Fewer total memories maxKMatchesPerStrategy: 5 // Fewer per strategy }}Generous Configuration (More Context)
Section titled “Generous Configuration (More Context)”siteFeatures: { userMemory: { enabled: true, maxMemoryRecordsPerPrompt: 40, // More total memories maxKMatchesPerStrategy: 20 // More per strategy }}Balance Considerations
Section titled “Balance Considerations”Lower Limits:
- Faster response times
- Lower token usage
- Less context per request
- Better for simple interactions
Higher Limits:
- More comprehensive context
- Better for complex conversations
- Higher token usage
- Slower response times
Step 4: Override Per Chat App (Optional)
Section titled “Step 4: Override Per Chat App (Optional)”Individual chat apps can customize or disable User Memory even if it's enabled site-wide.
Disable for Specific Chat App
Section titled “Disable for Specific Chat App”const simpleChatApp: ChatApp = { chatAppId: 'quick-answers', title: 'Quick Answers', // ... other properties features: { userMemory: { featureId: 'userMemory', enabled: false // Disable memory for this chat app } }};Customize Limits for Chat App
Section titled “Customize Limits for Chat App”const complexChatApp: ChatApp = { chatAppId: 'technical-support', title: 'Technical Support', // ... other properties features: { userMemory: { featureId: 'userMemory', enabled: true, maxMemoryRecordsPerPrompt: 50, // More context for complex support maxKMatchesPerStrategy: 25 // More memories per strategy } }};Step 5: Deploy and Test
Section titled “Step 5: Deploy and Test”Deploy Your Configuration
Section titled “Deploy Your Configuration”# If using local developmentcd apps/pika-chatpnpm run dev
# If deploying to AWScd services/pikapnpm run deployTest Memory Collection
Section titled “Test Memory Collection”- Start a chat session with a user
- Share preferences: "I prefer detailed technical explanations"
- Share context: "I'm a senior software engineer working on microservices"
- End the session
Test Memory Retrieval
Section titled “Test Memory Retrieval”- Start a NEW chat session with the same user
- Ask a technical question
- Observe: The AI should provide appropriately technical responses based on remembered context
Monitor Memory
Section titled “Monitor Memory”Check that memories are being:
- Collected during conversations
- Stored securely in AWS Bedrock
- Retrieved in subsequent sessions
- Applied to agent responses
Configuration Examples
Section titled “Configuration Examples”Example 1: Standard Customer Support
Section titled “Example 1: Standard Customer Support”siteFeatures: { userMemory: { enabled: true, maxMemoryRecordsPerPrompt: 20, maxKMatchesPerStrategy: 10 }}Example 2: Technical Documentation Assistant
Section titled “Example 2: Technical Documentation Assistant”siteFeatures: { userMemory: { enabled: true, maxMemoryRecordsPerPrompt: 35, // More context for technical topics maxKMatchesPerStrategy: 15 }}Example 3: Simple Q&A Bot (Memory Disabled)
Section titled “Example 3: Simple Q&A Bot (Memory Disabled)”siteFeatures: { userMemory: { enabled: false // No memory needed for simple Q&A }}Testing Checklist
Section titled “Testing Checklist”Verify User Memory is working correctly:
Troubleshooting
Section titled “Troubleshooting”Memory not being collected
Section titled “Memory not being collected”- Verify
enabled: truein site configuration - Check AWS Bedrock Agent Core Memory is available in your region
- Review agent prompts to ensure they encourage memorable exchanges
- Check CloudWatch logs for memory collection errors
Memory not being retrieved
Section titled “Memory not being retrieved”- Ensure new sessions are being created (not continuing old ones)
- Verify memory retrieval limits aren't set too low
- Check that memories exist in the database
- Review CloudWatch logs for retrieval errors
Too much/too little context
Section titled “Too much/too little context”- Adjust
maxMemoryRecordsPerPromptto control total memories - Modify
maxKMatchesPerStrategyto limit per-strategy memories - Consider different limits for different chat apps
Performance issues
Section titled “Performance issues”- Lower memory retrieval limits
- Review token usage in CloudWatch
- Consider disabling for simple chat apps that don't benefit from memory
Security and Privacy
Section titled “Security and Privacy”Data Isolation
Section titled “Data Isolation”- Each user's memory is completely isolated
- No cross-contamination between users
- Memory cannot be accessed by other users
Encryption
Section titled “Encryption”- All memory data is encrypted at rest
- Encrypted in transit using AWS security standards
- Follows AWS Bedrock security best practices
Data Retention
Section titled “Data Retention”- Memory data stays within your AWS environment
- Subject to your AWS data retention policies
- Can be purged as needed for compliance
Next Steps
Section titled “Next Steps”- Manage User Sessions - Control session behavior
- Work with Entities - Multi-tenant memory isolation
- Use Custom Message Tags - Tag messages with metadata
Related Documentation
Section titled “Related Documentation”- User Memory Capability - Learn more about memory features
- Session Management - Understanding sessions
- Agent Configuration Reference - Agent setup options