auto-claude-memory
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuto-Claude Memory System
Auto-Claude 内存系统
Graphiti-based persistent memory for cross-session context retention.
基于Graphiti的持久化内存,用于实现跨会话上下文保留。
Overview
概述
Auto-Claude uses Graphiti with embedded LadybugDB for memory:
- No Docker required - Embedded graph database
- Multi-provider support - OpenAI, Anthropic, Ollama, Google AI, Azure
- Semantic search - Find relevant context across sessions
- Knowledge graph - Entity relationships and facts
Auto-Claude 使用内置LadybugDB的Graphiti实现内存能力:
- 无需Docker - 嵌入式图数据库
- 多提供商支持 - OpenAI、Anthropic、Ollama、Google AI、Azure
- 语义搜索 - 跨会话查找相关上下文
- 知识图谱 - 存储实体关系与事实
Architecture
架构
Agent Session
│
▼
Memory Manager
│
├──▶ Add Episode (new learnings)
├──▶ Search Nodes (find entities)
├──▶ Search Facts (find relationships)
└──▶ Get Context (relevant memories)
│
▼
Graphiti (Knowledge Graph)
│
▼
LadybugDB (Embedded Storage)Agent Session
│
▼
Memory Manager
│
├──▶ Add Episode (新学习内容)
├──▶ Search Nodes (查找实体)
├──▶ Search Facts (查找关系)
└──▶ Get Context (相关记忆)
│
▼
Graphiti (知识图谱)
│
▼
LadybugDB (嵌入式存储)Configuration
配置
Enable Memory System
启用内存系统
In :
apps/backend/.envbash
undefined在 文件中配置:
apps/backend/.envbash
undefinedEnable Graphiti memory (default: true)
启用Graphiti内存(默认值:true)
GRAPHITI_ENABLED=true
undefinedGRAPHITI_ENABLED=true
undefinedProvider Selection
提供商选择
Choose LLM and embedding providers:
bash
undefined选择LLM和向量嵌入提供商:
bash
undefinedLLM provider: openai | anthropic | azure_openai | ollama | google | openrouter
LLM提供商可选值: openai | anthropic | azure_openai | ollama | google | openrouter
GRAPHITI_LLM_PROVIDER=openai
GRAPHITI_LLM_PROVIDER=openai
Embedder provider: openai | voyage | azure_openai | ollama | google | openrouter
嵌入模型提供商可选值: openai | voyage | azure_openai | ollama | google | openrouter
GRAPHITI_EMBEDDER_PROVIDER=openai
undefinedGRAPHITI_EMBEDDER_PROVIDER=openai
undefinedProvider Configurations
提供商配置
OpenAI (Simplest)
OpenAI(最简配置)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=openai
GRAPHITI_EMBEDDER_PROVIDER=openai
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxx
OPENAI_MODEL=gpt-4o-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-smallbash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=openai
GRAPHITI_EMBEDDER_PROVIDER=openai
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxx
OPENAI_MODEL=gpt-4o-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-smallAnthropic + Voyage (High Quality)
Anthropic + Voyage(高质量方案)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=anthropic
GRAPHITI_EMBEDDER_PROVIDER=voyage
ANTHROPIC_API_KEY=sk-ant-xxxxxxxx
GRAPHITI_ANTHROPIC_MODEL=claude-sonnet-4-5-latest
VOYAGE_API_KEY=pa-xxxxxxxx
VOYAGE_EMBEDDING_MODEL=voyage-3bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=anthropic
GRAPHITI_EMBEDDER_PROVIDER=voyage
ANTHROPIC_API_KEY=sk-ant-xxxxxxxx
GRAPHITI_ANTHROPIC_MODEL=claude-sonnet-4-5-latest
VOYAGE_API_KEY=pa-xxxxxxxx
VOYAGE_EMBEDDING_MODEL=voyage-3Ollama (Fully Offline)
Ollama(完全离线方案)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=ollama
GRAPHITI_EMBEDDER_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_LLM_MODEL=deepseek-r1:7b
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_EMBEDDING_DIM=768Prerequisites:
bash
undefinedbash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=ollama
GRAPHITI_EMBEDDER_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_LLM_MODEL=deepseek-r1:7b
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_EMBEDDING_DIM=768前置依赖:
bash
undefinedInstall Ollama
安装Ollama
curl -fsSL https://ollama.ai/install.sh | sh
curl -fsSL https://ollama.ai/install.sh | sh
Pull models
拉取模型
ollama pull deepseek-r1:7b
ollama pull nomic-embed-text
undefinedollama pull deepseek-r1:7b
ollama pull nomic-embed-text
undefinedGoogle AI (Gemini)
Google AI (Gemini)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=google
GRAPHITI_EMBEDDER_PROVIDER=google
GOOGLE_API_KEY=AIzaSyxxxxxxxx
GOOGLE_LLM_MODEL=gemini-2.0-flash
GOOGLE_EMBEDDING_MODEL=text-embedding-004bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=google
GRAPHITI_EMBEDDER_PROVIDER=google
GOOGLE_API_KEY=AIzaSyxxxxxxxx
GOOGLE_LLM_MODEL=gemini-2.0-flash
GOOGLE_EMBEDDING_MODEL=text-embedding-004Azure OpenAI (Enterprise)
Azure OpenAI(企业级方案)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=azure_openai
GRAPHITI_EMBEDDER_PROVIDER=azure_openai
AZURE_OPENAI_API_KEY=xxxxxxxx
AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com/...
AZURE_OPENAI_LLM_DEPLOYMENT=gpt-4
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-3-smallbash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=azure_openai
GRAPHITI_EMBEDDER_PROVIDER=azure_openai
AZURE_OPENAI_API_KEY=xxxxxxxx
AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com/...
AZURE_OPENAI_LLM_DEPLOYMENT=gpt-4
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-3-smallOpenRouter (Multi-Provider)
OpenRouter(多提供商聚合方案)
bash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=openrouter
GRAPHITI_EMBEDDER_PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-xxxxxxxx
OPENROUTER_LLM_MODEL=anthropic/claude-3.5-sonnet
OPENROUTER_EMBEDDING_MODEL=openai/text-embedding-3-smallbash
GRAPHITI_ENABLED=true
GRAPHITI_LLM_PROVIDER=openrouter
GRAPHITI_EMBEDDER_PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-xxxxxxxx
OPENROUTER_LLM_MODEL=anthropic/claude-3.5-sonnet
OPENROUTER_EMBEDDING_MODEL=openai/text-embedding-3-smallDatabase Settings
数据库设置
bash
undefinedbash
undefinedDatabase name (default: auto_claude_memory)
数据库名称(默认值:auto_claude_memory)
GRAPHITI_DATABASE=auto_claude_memory
GRAPHITI_DATABASE=auto_claude_memory
Storage path (default: ~/.auto-claude/memories)
存储路径(默认值:~/.auto-claude/memories)
GRAPHITI_DB_PATH=~/.auto-claude/memories
undefinedGRAPHITI_DB_PATH=~/.auto-claude/memories
undefinedMemory Operations
内存操作
How Memory Works
内存工作原理
-
During Build
- Agent discovers patterns, gotchas, solutions
- Memory Manager extracts insights
- Insights stored as episodes in knowledge graph
-
New Session
- Agent queries for relevant context
- Memory returns related insights
- Agent builds on previous learnings
-
构建过程中
- Agent发现模式、注意事项、解决方案
- 内存管理器提取洞察信息
- 洞察作为事件存储在知识图谱中
-
新会话启动时
- Agent查询相关上下文
- 内存返回关联的历史洞察
- Agent基于之前的学习内容继续开发
MCP Tools
MCP工具
When is set, agents can use:
GRAPHITI_MCP_URL| Tool | Purpose |
|---|---|
| Search entity summaries |
| Search relationships between entities |
| Add data to knowledge graph |
| Retrieve recent episodes |
| Get specific entity/relationship |
当配置了时,Agent可以使用以下工具:
GRAPHITI_MCP_URL| 工具 | 用途 |
|---|---|
| 搜索实体摘要 |
| 搜索实体之间的关系 |
| 向知识图谱添加数据 |
| 拉取近期事件 |
| 获取指定实体/关系 |
Python API
Python API
python
from integrations.graphiti.memory import get_graphiti_memorypython
from integrations.graphiti.memory import get_graphiti_memoryGet memory instance
获取内存实例
memory = get_graphiti_memory(spec_dir, project_dir)
memory = get_graphiti_memory(spec_dir, project_dir)
Get context for session
获取会话上下文
context = memory.get_context_for_session("Implementing feature X")
context = memory.get_context_for_session("Implementing feature X")
Add insight from session
新增会话洞察
memory.add_session_insight("Pattern: use React hooks for state")
memory.add_session_insight("Pattern: use React hooks for state")
Search for relevant memories
搜索相关记忆
results = memory.search("authentication patterns")
undefinedresults = memory.search("authentication patterns")
undefinedMemory Storage
内存存储
Location
存储位置
~/.auto-claude/memories/
├── auto_claude_memory/ # Main database
│ ├── nodes/ # Entity nodes
│ ├── edges/ # Relationships
│ └── episodes/ # Session insights
└── embeddings/ # Vector embeddings~/.auto-claude/memories/
├── auto_claude_memory/ # 主数据库
│ ├── nodes/ # 实体节点
│ ├── edges/ # 关系
│ └── episodes/ # 会话洞察
└── embeddings/ # 向量嵌入Per-Spec Memory
单规格内存
.auto-claude/specs/001-feature/
└── graphiti/ # Spec-specific memory
├── insights.json # Extracted insights
└── context.json # Session context.auto-claude/specs/001-feature/
└── graphiti/ # 规格专属内存
├── insights.json # 提取的洞察信息
└── context.json # 会话上下文Querying Memory
查询内存
Command Line
命令行查询
bash
cd apps/backendbash
cd apps/backendQuery memory
查询内存
python query_memory.py --search "authentication"
python query_memory.py --search "authentication"
List recent episodes
列出近期事件
python query_memory.py --recent 10
python query_memory.py --recent 10
Get entity details
获取实体详情
python query_memory.py --entity "UserService"
undefinedpython query_memory.py --entity "UserService"
undefinedMemory in Action
内存使用示例
Example session:
Session 1:
Agent: "Implemented OAuth login, discovered need to handle token refresh"
Memory: Stores insight about token refresh pattern
Session 2:
Agent: "Implementing user profile..."
Memory: "Previously learned about token refresh in OAuth implementation"
Agent: Uses learned pattern for profile API calls会话示例:
会话1:
Agent: "已实现OAuth登录,发现需要处理令牌刷新逻辑"
内存: 存储令牌刷新模式的洞察信息
会话2:
Agent: "正在实现用户profile功能..."
内存: "此前在OAuth实现中学习到令牌刷新相关逻辑"
Agent: 将已学习的模式应用到profile API调用中Best Practices
最佳实践
Effective Memory Use
高效使用内存
-
Let agents learn naturally
- Don't force memory storage
- Agents automatically extract insights
-
Use semantic search
- Query with natural language
- Memory finds related concepts
-
Clean up periodically
- Remove outdated insights
- Update incorrect information
-
让Agent自然学习
- 不要强制存储记忆
- Agent会自动提取洞察信息
-
使用语义搜索
- 用自然语言查询
- 内存会自动匹配相关概念
-
定期清理
- 移除过时的洞察信息
- 更新错误的内容
Provider Selection
提供商选择建议
| Use Case | Recommended |
|---|---|
| Production | OpenAI or Anthropic+Voyage |
| Development | Ollama (free, offline) |
| Enterprise | Azure OpenAI |
| Budget | OpenRouter or Google AI |
| 场景 | 推荐方案 |
|---|---|
| 生产环境 | OpenAI 或 Anthropic+Voyage |
| 开发环境 | Ollama(免费、离线) |
| 企业级场景 | Azure OpenAI |
| 预算有限场景 | OpenRouter 或 Google AI |
Performance Tips
性能优化技巧
-
Embedding model selection
- : Fast, good quality
text-embedding-3-small - : Better quality, slower
text-embedding-3-large
-
LLM model selection
- : Fast, cost-effective
gpt-4o-mini - : High quality reasoning
claude-sonnet
-
Ollama optimizationbash
# Use smaller models for speed OLLAMA_LLM_MODEL=llama3.2:3b OLLAMA_EMBEDDING_MODEL=all-minilm OLLAMA_EMBEDDING_DIM=384
-
嵌入模型选择
- : 速度快、质量佳
text-embedding-3-small - : 质量更高、速度较慢
text-embedding-3-large
-
LLM模型选择
- : 速度快、性价比高
gpt-4o-mini - : 推理质量高
claude-sonnet
-
Ollama优化bash
# 用更小的模型提升速度 OLLAMA_LLM_MODEL=llama3.2:3b OLLAMA_EMBEDDING_MODEL=all-minilm OLLAMA_EMBEDDING_DIM=384
Troubleshooting
故障排查
Memory Not Working
内存不工作
bash
undefinedbash
undefinedCheck if enabled
检查是否已启用
grep GRAPHITI apps/backend/.env
grep GRAPHITI apps/backend/.env
Verify provider credentials
验证提供商凭证
python -c "from integrations.graphiti.memory import get_graphiti_memory; print('OK')"
undefinedpython -c "from integrations.graphiti.memory import get_graphiti_memory; print('OK')"
undefinedProvider Errors
提供商报错
bash
undefinedbash
undefinedOpenAI
测试OpenAI
curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/models
curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/models
Ollama
测试Ollama
Check logs
查看日志
DEBUG=true python query_memory.py --search "test"
undefinedDEBUG=true python query_memory.py --search "test"
undefinedDatabase Corruption
数据库损坏
bash
undefinedbash
undefinedBackup and reset
备份并重置
mv ~/.auto-claude/memories ~/.auto-claude/memories.backup
python query_memory.py --search "test" # Creates fresh DB
undefinedmv ~/.auto-claude/memories ~/.auto-claude/memories.backup
python query_memory.py --search "test" # 会创建全新的数据库
undefinedEmbedding Dimension Mismatch
向量嵌入维度不匹配
If changing embedding models:
bash
undefined如果更换了嵌入模型:
bash
undefinedClear existing embeddings
清除现有嵌入
rm -rf ~/.auto-claude/memories/embeddings
rm -rf ~/.auto-claude/memories/embeddings
Restart to re-embed
重启服务重新生成嵌入
python run.py --spec 001
undefinedpython run.py --spec 001
undefinedAdvanced Usage
高级用法
Custom Memory Integration
自定义内存集成
python
from integrations.graphiti.queries_pkg.graphiti import GraphitiMemorypython
from integrations.graphiti.queries_pkg.graphiti import GraphitiMemoryCreate custom memory instance
创建自定义内存实例
memory = GraphitiMemory(
database="custom_db",
db_path="/path/to/storage",
llm_provider="anthropic",
embedder_provider="voyage"
)
memory = GraphitiMemory(
database="custom_db",
db_path="/path/to/storage",
llm_provider="anthropic",
embedder_provider="voyage"
)
Custom operations
自定义操作
memory.add_entity("UserService", {"type": "service", "purpose": "auth"})
memory.add_relationship("UserService", "uses", "Database")
undefinedmemory.add_entity("UserService", {"type": "service", "purpose": "auth"})
memory.add_relationship("UserService", "uses", "Database")
undefinedMemory MCP Server
内存MCP服务
Run standalone memory server:
bash
undefined运行独立的内存服务:
bash
undefinedStart Graphiti MCP server
启动Graphiti MCP服务
GRAPHITI_MCP_URL=http://localhost:8000/mcp/ python -m integrations.graphiti.server
undefinedGRAPHITI_MCP_URL=http://localhost:8000/mcp/ python -m integrations.graphiti.server
undefinedRelated Skills
相关技能
- auto-claude-setup: Initial configuration
- auto-claude-optimization: Performance tuning
- auto-claude-troubleshooting: Debugging
- auto-claude-setup: 初始配置
- auto-claude-optimization: 性能调优
- auto-claude-troubleshooting: 调试排错