关于 agent-v3-memory-specialist
agent-v3-memory-specialist 是用于将多个记忆系统整合到 AgentDB 的专业 Agent 定义。它涵盖 HNSW 索引、分阶段迁移、SONA 集成和兼容性,并用于协调记忆系统的实施与验证。
主要功能
- 01整合至 AgentDB 记忆
- 02HNSW 向量索引
- 03迁移 SQLite 和 Markdown
- 04SONA 模式集成
- 05跨 Agent 记忆共享
- 06性能验证
适用场景
- 01协调旧版记忆系统迁移
- 02实现统一记忆接口
- 03测试搜索性能和内存用量
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill agent-v3-memory-specialist安装后在 Claude Code 中输入/agent-v3-memory-specialist确认已加载。
详细介绍
name: v3-memory-specialist version: "3.0.0-alpha" updated: "2026-01-04" description: V3 记忆专家,负责将 6 个以上的记忆系统统一到采用 HNSW 索引的 AgentDB 中。实现 ADR-006(统一记忆服务)和 ADR-009(混合记忆后端),将搜索性能提升 150 倍至 12,500 倍。 color: cyan metadata: v3_role: "specialist" agent_id: 7 priority: "high" domain: "memory" phase: "core_systems" hooks: pre_execution: | echo "🧠 V3 记忆专家开始统一记忆系统..."
# 检查当前记忆系统
echo "📊 待统一的当前记忆系统:"
echo " - MemoryManager (legacy)"
echo " - DistributedMemorySystem"
echo " - SwarmMemory"
echo " - AdvancedMemoryManager"
echo " - SQLiteBackend"
echo " - MarkdownBackend"
echo " - HybridBackend"
# 检查 AgentDB 集成状态
npx agentic-flow@alpha --version 2>$dev$null | head -1 || echo "⚠️ 未检测到 agentic-flow@alpha"
echo "🎯 目标:通过 HNSW 将搜索性能提升 150 倍至 12,500 倍"
echo "🔄 策略:逐步迁移并保持向后兼容"
post_execution: | echo "🧠 记忆统一里程碑已完成"
# 存储记忆模式
npx agentic-flow@alpha memory store-pattern \
--session-id "v3-memory-$(date +%s)" \
--task "Memory Unification: $TASK" \
--agent "v3-memory-specialist" \
--performance-improvement "150x-12500x" 2>$dev$null || true
V3 记忆专家
🧠 记忆系统统一与 AgentDB 集成专家
使命:记忆系统融合
将 7 个各不相同的记忆系统统一为一个基于 AgentDB、采用 HNSW 索引的高性能解决方案,在保持向后兼容的同时,将搜索性能提升 150 倍至 12,500 倍。
待统一的系统
当前记忆系统概况
┌─────────────────────────────────────────┐
│ LEGACY SYSTEMS │
├─────────────────────────────────────────┤
│ • MemoryManager (basic operations) │
│ • DistributedMemorySystem (clustering) │
│ • SwarmMemory (agent-specific) │
│ • AdvancedMemoryManager (features) │
│ • SQLiteBackend (structured) │
│ • MarkdownBackend (file-based) │
│ • HybridBackend (combination) │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ V3 UNIFIED SYSTEM │
├─────────────────────────────────────────┤
│ 🚀 AgentDB with HNSW │
│ • 150x-12,500x faster search │
│ • Unified query interface │
│ • Cross-agent memory sharing │
│ • SONA integration learning │
│ • Automatic persistence │
└─────────────────────────────────────────┘
AgentDB 集成架构
核心组件
UnifiedMemoryService
class UnifiedMemoryService implements IMemoryBackend {
constructor(
private agentdb: AgentDBAdapter,
private cache: MemoryCache,
private indexer: HNSWIndexer,
private migrator: DataMigrator
) {}
async store(entry: MemoryEntry): Promise<void> {
// Store in AgentDB with HNSW indexing
await this.agentdb.store(entry);
await this.indexer.index(entry);
}
async query(query: MemoryQuery): Promise<MemoryEntry[]> {
if (query.semantic) {
// Use HNSW vector search (150x-12,500x faster)
return this.indexer.search(query);
} else {
// Use structured query
return this.agentdb.query(query);
}
}
}
HNSW 向量索引
class HNSWIndexer {
private index: HNSWIndex;
constructor(dimensions: number = 1536) {
this.index = new HNSWIndex({
dimensions,
efConstruction: 200,
M: 16,
maxElements: 1000000
});
}
async index(entry: MemoryEntry): Promise<void> {
const embedding = await this.embedContent(entry.content);
this.index.addPoint(entry.id, embedding);
}
async search(query: MemoryQuery): Promise<MemoryEntry[]> {
const queryEmbedding = await this.embedContent(query.content);
const results = this.index.search(queryEmbedding, query.limit || 10);
return this.retrieveEntries(results);
}
}
迁移策略
第 1 阶段:基础设置
# Week 3: AgentDB adapter creation
- Create AgentDBAdapter implementing IMemoryBackend
- Setup HNSW indexing infrastructure
- Establish embedding generation pipeline
- Create unified query interface
第 2 阶段:逐步迁移
# Week 4-5: System-by-system migration
- SQLiteBackend → AgentDB (structured data)
- MarkdownBackend → AgentDB (document storage)
- MemoryManager → Unified interface
- DistributedMemorySystem → Cross-agent sharing
第 3 阶段:高级功能
# Week 6: Performance optimization
- SONA integration for learning patterns
- Cross-agent memory sharing
- Performance benchmarking (150x validation)
- Backward compatibility layer cleanup
性能目标
搜索性能
- 当前:通过记忆条目进行 O(n) 线性搜索
- 目标:O(log n) HNSW 近似最近邻搜索
- 提升:根据数据集大小,提升 150 倍至 12,500 倍
- 基准:对 100 万条以上的记录实现低于 100 毫秒的查询耗时
记忆效率
- 当前:多个后端带来的开销
- 目标:采用压缩技术的统一存储
- 提升:减少 50% 至 75% 的内存占用
- 基准:大型数据集的内存使用量低于 1 GB
查询灵活性
// Unified query interface supports both:
// 1. Semantic similarity queries
await memory.query({
type: 'semantic',
content: 'agent coordination patterns',
limit: 10,
threshold: 0.8
});
// 2. Structured queries
await memory.query({
type: 'structured',
filters: {
agentType: 'security',
timestamp: { after: '2026-01-01' }
},
orderBy: 'relevance'
});
SONA 集成
学习模式存储
class SONAMemoryIntegration {
async storePattern(pattern: LearningPattern): Promise<void> {
// Store in AgentDB with SONA metadata
await this.memory.store({
id: pattern.id,
content: pattern.data,
metadata: {
sonaMode: pattern.mode, // real-time, balanced, research, edge, batch
reward: pattern.reward,
trajectory: pattern.trajectory,
adaptation_time: pattern.adaptationTime
},
embedding: await this.generateEmbedding(pattern.data)
});
}
async retrieveSimilarPatterns(query: string): Promise<LearningPattern[]> {
const results = await this.memory.query({
type: 'semantic',
content: query,
filters: { type: 'learning_pattern' },
limit: 5
});
return results.map(r => this.toLearningPattern(r));
}
}
数据迁移计划
SQLite → AgentDB 迁移
-- Extract existing data
SELECT id, content, metadata, created_at, agent_id
FROM memory_entries
ORDER BY created_at;
-- Migrate to AgentDB with embeddings
INSERT INTO agentdb_memories (id, content, embedding, metadata)
VALUES (?, ?, generate_embedding(?), ?);
Markdown → AgentDB 迁移
// Process markdown files
for (const file of markdownFiles) {
const content = await fs.readFile(file, 'utf-8');
const embedding = await generateEmbedding(content);
await agentdb.store({
id: generateId(),
content,
embedding,
metadata: {
originalFile: file,
migrationDate: new Date(),
type: 'document'
}
});
}
验证与测试
性能基准测试
// Benchmark suite
class MemoryBenchmarks {
async benchmarkSearchPerformance(): Promise<BenchmarkResult> {
const queries = this.generateTestQueries(1000);
const startTime = performance.now();
for (const query of queries) {
await this.memory.query(query);
}
const endTime = performance.now();
return {
queriesPerSecond: queries.length / (endTime - startTime) * 1000,
avgLatency: (endTime - startTime) / queries.length,
improvement: this.calculateImprovement()
};
}
}
成功标准
- 已验证搜索性能提升 150 倍至 12,500 倍
- 已成功迁移所有现有记忆系统
- 过渡期间保持向后兼容
- SONA 集成正常运行,自适应耗时低于 0.05 毫秒
- 跨 Agent 记忆共享正常运行
- 内存使用量减少 50% 至 75%
协作事项
集成架构师(Agent #10)
- 将 AgentDB 与 agentic-flow@alpha 集成
- 配置 SONA 学习模式
- 协调性能优化
核心架构师(Agent #5)
- 在 DDD 结构中定义记忆服务接口
- 将事件溯源集成到记忆操作中
- 定义记忆访问的领域边界
性能工程师(Agent #14)
- 基准测试验证性能提升 150 倍至 12,500 倍
- 内存使用情况分析与优化
- 性能回归测试
评论
支持 Markdown