What are Custom Instructions?

Custom instructions are natural language guidelines that tell Mem0 exactly what information to extract and remember from conversations. Think of them as smart filters that ensure your AI application captures only the most relevant data for your specific use case.
# Simple example: Health app focusing on wellness
prompt = """
Extract only health and wellness information:
- Symptoms, medications, and treatments
- Exercise routines and dietary habits
- Doctor appointments and health goals

Exclude: Personal identifiers, financial data
"""

client.project.update(custom_instructions=prompt)

Why Use Custom Instructions?

  • Focus on What Matters: Only capture information relevant to your application
  • Maintain Privacy: Explicitly exclude sensitive data like passwords or personal identifiers
  • Ensure Consistency: All memories follow the same extraction rules across your project
  • Improve Quality: Filter out noise and irrelevant conversations

How to Set Custom Instructions

Basic Setup

# Set instructions for your project
client.project.update(custom_instructions="Your guidelines here...")

# Retrieve current instructions
response = client.project.get(fields=["custom_instructions"])
print(response["custom_instructions"])

Best Practice Template

Structure your instructions using this proven template:
Your Task: [Brief description of what to extract]

Information to Extract:
1. [Category 1]:
   - [Specific details]
   - [What to look for]

2. [Category 2]:
   - [Specific details]
   - [What to look for]

Guidelines:
- [Processing rules]
- [Quality requirements]

Exclude:
- [Sensitive data to avoid]
- [Irrelevant information]

Real-World Examples

instructions = """
Extract customer service information for better support:

1. Product Issues:
   - Product names, SKUs, defects
   - Return/exchange requests
   - Quality complaints

2. Customer Preferences:
   - Preferred brands, sizes, colors
   - Shopping frequency and habits
   - Price sensitivity

3. Service Experience:
   - Satisfaction with support
   - Resolution time expectations
   - Communication preferences

Exclude: Payment card numbers, passwords, personal identifiers.
"""

client.project.update(custom_instructions=instructions)

Advanced Techniques

Conditional Processing

Handle different conversation types with conditional logic:
advanced_prompt = """
Extract information based on conversation context:

IF customer support conversation:
- Issue type, severity, resolution status
- Customer satisfaction indicators

IF sales conversation:
- Product interests, budget range
- Decision timeline and influencers

IF onboarding conversation:
- User experience level
- Feature interests and priorities

Always exclude personal identifiers and maintain professional context.
"""

client.project.update(custom_instructions=advanced_prompt)

Testing Your Instructions

Always test your custom instructions with real messages examples:
# Test with sample messages
messages = [
    {"role": "user", "content": "I'm having billing issues with my subscription"},
    {"role": "assistant", "content": "I can help with that. What's the specific problem?"},
    {"role": "user", "content": "I'm being charged twice each month"}
]

# Add the messages and check extracted memories
result = client.add(messages, user_id="test_user")
memories = client.get_all(user_id="test_user")

# Review if the right information was extracted
for memory in memories:
    print(f"Extracted: {memory['memory']}")

Best Practices

✅ Do

  • Be specific about what information to extract
  • Use clear categories to organize your instructions
  • Test with real conversations before deploying
  • Explicitly state exclusions for privacy and compliance
  • Start simple and iterate based on results

❌ Don’t

  • Make instructions too long or complex
  • Create conflicting rules within your guidelines
  • Be overly restrictive (balance specificity with flexibility)
  • Forget to exclude sensitive information
  • Skip testing with diverse conversation examples

Common Issues and Solutions

IssueSolution
Instructions too longBreak into focused categories, keep concise
Missing important dataAdd specific examples of what to capture
Capturing irrelevant infoStrengthen exclusion rules and be more specific
Inconsistent resultsClarify guidelines and test with more examples