Skip to main content

What are Custom Instructions?

Custom instructions are natural language guidelines that let you define exactly what Mem0 should include or exclude when creating memories from conversations. This gives you precise control over what information is extracted, acting as smart filters so your AI application only remembers what matters for your use case.

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

project.get() always returns the full project object. The fields parameter is accepted but has no filtering effect server-side, so response["custom_instructions"] above is a key on the full response, not a pre-filtered payload.

Best Practice Template

Structure your instructions using this proven template:

Agent Custom Instructions

custom_instructions applies to every memory your project extracts, no matter whose it is. But what is worth remembering about an agent is rarely what is worth remembering about a user: an agent’s useful memories are things like which tools fail, which retry strategies work, and how a given environment behaves, not personal preferences. agent_custom_instructions is an optional second set of extraction rules that applies only to agent-scoped memories. Available from Python SDK v2.0.17 and TypeScript SDK v3.1.5. Upgrade first if you are on an earlier release. Set it on the project alongside custom_instructions:

Which instructions apply

Which set governs an add() call depends on the entity IDs you pass with it: agent_custom_instructions is unset by default. While it is unset, custom_instructions applies to every memory, so projects that don’t set it behave exactly as they did before.

Overriding for a single call

Both fields are also accepted per request, overriding the project setting for that add() only:

Reading and clearing

Real-World Examples

Advanced Techniques

Conditional Processing

Handle different conversation types with conditional logic:

Testing Your Instructions

Always test your custom instructions with real message examples:

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