Skip to content

Configure User Memory

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.

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
  • A running Pika installation
  • Access to pika-config.ts for site-level configuration
  • Basic understanding of your chat app structure
  • AWS environment with Bedrock Agent Core Memory available

User Memory automatically captures and stores information about users during conversations, then retrieves relevant context in future sessions.

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
  1. During Conversations: The system identifies memorable information from user messages
  2. Storage: Insights are securely stored in AWS Bedrock Agent Core Memory with user-specific isolation
  3. Retrieval: When users start new conversations, relevant memories are retrieved and injected into prompts
  4. Updates: Memory is updated as new information becomes available

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
}
}
};
PropertyTypeDefaultDescription
enabledbooleanfalseEnable/disable user memory collection and retrieval
maxMemoryRecordsPerPromptnumber25Maximum total memory results to include in a single prompt
maxKMatchesPerStrategynumber10Maximum memories to retrieve per strategy (preferences, semantic)

When you enable User Memory, both preferences and semantic strategies are automatically enabled by default.

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
}
}
siteFeatures: {
userMemory: {
enabled: true,
maxMemoryRecordsPerPrompt: 40, // More total memories
maxKMatchesPerStrategy: 20 // More per strategy
}
}

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

Individual chat apps can customize or disable User Memory even if it's enabled site-wide.

const simpleChatApp: ChatApp = {
chatAppId: 'quick-answers',
title: 'Quick Answers',
// ... other properties
features: {
userMemory: {
featureId: 'userMemory',
enabled: false // Disable memory for this 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
}
}
};
Terminal window
# If using local development
cd apps/pika-chat
pnpm run dev
# If deploying to AWS
cd services/pika
pnpm run deploy
  1. Start a chat session with a user
  2. Share preferences: "I prefer detailed technical explanations"
  3. Share context: "I'm a senior software engineer working on microservices"
  4. End the session
  1. Start a NEW chat session with the same user
  2. Ask a technical question
  3. Observe: The AI should provide appropriately technical responses based on remembered context

Check that memories are being:

  • Collected during conversations
  • Stored securely in AWS Bedrock
  • Retrieved in subsequent sessions
  • Applied to agent responses
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
}
}
siteFeatures: {
userMemory: {
enabled: false // No memory needed for simple Q&A
}
}

Verify User Memory is working correctly:

  • Verify enabled: true in 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
  • 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
  • Adjust maxMemoryRecordsPerPrompt to control total memories
  • Modify maxKMatchesPerStrategy to limit per-strategy memories
  • Consider different limits for different chat apps
  • Lower memory retrieval limits
  • Review token usage in CloudWatch
  • Consider disabling for simple chat apps that don't benefit from memory
  • Each user's memory is completely isolated
  • No cross-contamination between users
  • Memory cannot be accessed by other users
  • All memory data is encrypted at rest
  • Encrypted in transit using AWS security standards
  • Follows AWS Bedrock security best practices
  • Memory data stays within your AWS environment
  • Subject to your AWS data retention policies
  • Can be purged as needed for compliance