graph TB subgraph "Input Processing" A[User Input] --> B[Meta Agent] end subgraph "Memory Managers" C[Core Memory Manager] D[Episodic Memory Manager] E[Semantic Memory Manager] F[Procedural Memory Manager] G[Resource Memory Manager] H[Knowledge Vault Manager] end subgraph "User Interaction" I[Chat Agent] end subgraph "Memory Base" J[(Shared Memory Database)] end B --> C B --> D B --> E B --> F B --> G B --> H C --> J D --> J E --> J F --> J G --> J H --> J I --> J J --> I最大特色是可以支持图片生成记忆(后续专门写一篇文章分析如何实现的)。所有记忆都是通过 LLM Agent 生成,核心是 Prompt 工程,实际使用体验并不是很稳定。
记忆类型
1. Core Memory 核心记忆
代理与用户交互时应始终可见的持久性信息,核心记忆被组织在多个 block 中( human 和 persona )
<human 117/500 characters>User's name is DavidUser prefers coffee over teaUser works as a software engineerUser enjoys reading sci-fi novels</human><persona 24/5000 characters>I am a helpful assistant</persona>2. Episodic Memory 情景记忆
捕获特定于上下文的事件和时间活动,作为用户行为的摘要或日历。
{ "event_type": "user_message", "summary": "User reviewed quarterly sales report", "details": "Detailed analysis of Q3 sales performance, identified key growth areas in mobile segment, discussed strategies with marketing team", "actor": "user", "timestamp": "2025-03-05 10:15"}3. Semantic Memory 语义记忆
维护一般知识,概念和独立于时间的上下文抽象信息。
[ { "name": "PostgreSQL", "summary": "Open-source relational database management system", "details": "Powerful, enterprise-grade database with advanced features like JSONB support, full-text search, and vector extensions. Preferred by user for its performance and reliability.", "source": "user_interaction" }, { "name": "MkDocs Material", "summary": "Documentation framework based on MkDocs", "details": "Static site generator that creates beautiful documentation sites from Markdown files. Features include responsive design, search functionality, and extensive customization options.", "source": "documentation_project" }, { "name": "Team Standup Meeting", "summary": "Daily team synchronization meeting", "details": "Occurs every weekday at 9 AM, attended by development team to discuss progress, blockers, and daily goals. Usually lasts 15-20 minutes.", "source": "recurring_activity" }]包含的数据内容类型:
- 事实知识 :“哈利波特是由 J. K。罗琳”关于其他人的事实和理解 :“John 是用户的好朋友,喜欢慢跑”概念 :“机器学习算法及其应用”
4. Procedural Memory 程序性记忆
记录完成特定任务的流程工作流和分步说明。
[ { "entry_type": "workflow", "description": "Setting up new development environment", "steps": [ "1. Install Python 3.11 or later", "2. Set up virtual environment with 'python -m venv venv'", "3. Activate virtual environment", "4. Install dependencies with 'pip install -r requirements.txt'", "5. Configure environment variables in .env file", "6. Initialize database with 'python manage.py migrate'", "7. Run development server with 'python manage.py runserver'" ] }, { "entry_type": "guide", "description": "Troubleshooting PostgreSQL connection issues", "steps": [ "1. Check if PostgreSQL service is running", "2. Verify database exists with 'psql -l'", "3. Test connection with 'psql -U username -d database'", "4. Check firewall settings if connecting remotely", "5. Verify authentication configuration in pg_hba.conf" ] }]5. Resource Memory 资源存储器
管理与用户交互的活动文档和项目相关文件。
[ { "title": "API Documentation Draft", "summary": "Initial draft of REST API documentation for the customer management system, includes endpoint specifications and example requests", "resource_type": "markdown", "content": "# Customer Management API\n\n## Overview\nThis API provides endpoints for managing customer data...\n\n## Endpoints\n\n### GET /api/customers\nRetrieve list of customers..." }, { "title": "Meeting Recording - Sprint Planning", "summary": "Voice recording from sprint planning meeting discussing user stories and development priorities for next iteration", "resource_type": "voice_transcript", "content": "Transcript: 'Let's start with the user authentication story. Based on our previous discussion, we need to implement OAuth 2.0 integration...'" }]6. Knowledge Vault
存储结构化的个人数据敏感数据,如地址、电话号码、联系人和凭据。
[ { "entry_type": "api_key", "source": "openai", "sensitivity": "high", "secret_value": "sk-proj-xxxxxxxxxxxxxxxxxxxx", "caption": "OpenAI API key for ChatGPT integration" }, { "entry_type": "bookmark", "source": "user_provided", "sensitivity": "low", "secret_value": "https://docs.mirix.ai/", "caption": "MIRIX documentation website" }, { "entry_type": "contact_info", "source": "user_profile", "sensitivity": "medium", "secret_value": "john.doe@example.com", "caption": "Primary email address" }]主要参数说明:
Sensitivity Levels 灵敏度水平
- low: 一般书签和公共信息medium: 联系信息和非关键数据high: 密码、API 密钥和敏感凭据
Security Features 安全功能
- Encryption: 静态加密敏感数据Access Control: 访问控制:根据敏感度级别限制访问Audit Trail: 审计跟踪:记录对敏感数据的所有访问Automatic Expiration: 自动过期:凭据可以有过期日期
记忆搜索
所有类型的记忆都使用统一的搜索接口
results = search_in_memory( query="machine learning project", memory_type='episodic', # can be chosen from ['all', 'episodic', 'semantic', 'resource', 'procedural', 'knowledge_vault'] limit=20)3 种搜索实现方式:
| Method | Description | Best For | Performance |
|---|---|---|---|
bm25 | 推荐 - PostgreSQL 原生全文搜索 | 大多数查询,生产使用 | Excellent |
embedding | 使用嵌入的向量相似性搜索 | 语义相似性,概念查询 | Good |
string_match | 简单字符串包含搜索 | 精确文本匹配 | Fast |
记忆自动清理策略
- Core Memory: 接近容量上限时会覆盖旧的记忆Episodic Memory: 根据相关性归档旧条目Semantic Memory: 合并重复的概念Procedural Memory: 根据使用模式更新工作流Resource Memory: 压缩或删除未使用的资源,需要明确具体策略Knowledge Vault: 到期删除
