Memory System
Give your agents persistent memory using markdown-based storage.
Quick Start
What is Memory?
Memory is a simple, file-based storage system that lets your agents:
Persistent Storage
Save information across sessions
Key-Value Retrieval
Retrieve information by specific keys
Regex Search
Search across all memories with patterns
Markdown Format
Organize knowledge in human-readable format
Storage Strategy
Memories start in a single memory.md file. When the file exceeds 3000 lines, it automatically splits into a directory structure with separate .md files per memory key.
Installation
Memory is included in ConnectOnion:
Basic Usage
Creating a Memory Instance
Adding Memory to an Agent
Now your agent has access to 4 memory methods:
- write_memory(key, content)- Save or update information
- read_memory(key)- Retrieve information
- list_memories()- Show all stored memories
- search_memory(pattern)- Search with regex
Memory Methods
write_memory
Save information to memory:
read_memory
Retrieve saved information:
list_memories
Show all stored memories:
search_memory
Search across all memories using regex:
Examples
Example 1: Customer Notes
Example 2: Project Tracker
Example 3: Research Assistant
File Format
Single File (Default)
Memories start in a single memory.md file using section headers:
Works at TechCorp
Prefers phone calls
Auto-Split to Directory
When memory.md exceeds 3000 lines, it automatically migrates:
Best Practices
1. Use Descriptive Keys
2. Structure Your Content
Use markdown formatting for better organization:
