Skip to main content
The basic memory setup covers most use cases, but sometimes you need more control. This guide covers advanced patterns for customizing memory behavior, controlling what gets stored, and building complex multi-agent systems with shared memory.

Customizing the Memory Manager

The MemoryManager controls which LLM creates and updates memories, plus how those memories are generated. You can customize it to use a specific model, add privacy rules, or change how memories are extracted:
In this example, the memory manager will store memories about hobbies, but won’t include the user’s actual name. This is useful for healthcare, legal, or other privacy-sensitive applications.

Memories and Context

When enabled, memories about the current user are automatically added to the agent’s context on each request. But in some scenarios, like when you’re building analytics on memories or want the agent to explicitly search for memories using tools, you might want to store memories without auto-including them. Use add_memories_to_context=False to collect memories in the background while keeping the agent’s context lean:

Memory Optimization

As users accumulate memories over time, and these memories are added to your context on each request, token costs can grow significantly. Memory optimization helps reduce these costs by combining multiple memories into fewer, more efficient memories while preserving all the key information. When to optimize:
  • Users with 50+ memories
  • Before high-cost operations
  • Periodic maintenance for long-running applications
See the Memory Optimization guide for detailed usage and best practices.

Using Memory Tools

Instead of automatic memory management, you can give your agent explicit tools to create, retrieve, update, and delete memories. This approach gives the agent more control and reasoning ability, so it can decide when to store something versus when to search for existing memories. When to use Memory Tools:
  • You want the agent to reason about whether something is worth remembering
  • You need fine-grained control over memory operations (create, update, delete separately)
  • You’re building a system where the agent should explicitly search memories rather than having them auto-loaded
See the Memory Tools documentation for more details.

Sharing Memory Between Agents

In multi-agent systems, you often want agents to share knowledge about users. For example, a support agent might learn a user’s preferences, and a sales agent should be aware of them too. This is simple in Agno: just connect multiple agents to the same database.
All agents connected to the same database automatically share memories for each user. This works across agent types, teams, and workflows, as long as they use the same user_id.

Developer Resources