MCP HubMCP Hub
返回技能列表

agentdb-persistent-memory-patterns

DNYoussef
更新于 Today
58 次查看
9
2
9
在 GitHub 上查看
design

关于

This skill provides patterns for implementing persistent memory in AI agents using AgentDB, including session management, long-term storage, and context handling. Use it when building stateful agents, chat systems, or assistants that require memory across interactions. It offers a structured SOP covering architecture design, storage implementation, and testing of memory operations.

快速安装

Claude Code

推荐
插件命令推荐
/plugin add https://github.com/DNYoussef/context-cascade
Git 克隆备选方式
git clone https://github.com/DNYoussef/context-cascade.git ~/.claude/skills/agentdb-persistent-memory-patterns

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

AgentDB Persistent Memory Patterns

Overview

Implement persistent memory patterns for AI agents using AgentDB - session memory, long-term storage, pattern learning, and context management for stateful agents, chat systems, and intelligent assistants.

SOP Framework: 5-Phase Memory Implementation

Phase 1: Design Memory Architecture (1-2 hours)

  • Define memory schemas (episodic, semantic, procedural)
  • Plan storage layers (short-term, working, long-term)
  • Design retrieval mechanisms
  • Configure persistence strategies

Phase 2: Implement Storage Layer (2-3 hours)

  • Create memory stores in AgentDB
  • Implement session management
  • Build long-term memory persistence
  • Setup memory indexing

Phase 3: Test Memory Operations (1-2 hours)

  • Validate store/retrieve operations
  • Test memory consolidation
  • Verify pattern recognition
  • Benchmark performance

Phase 4: Optimize Performance (1-2 hours)

  • Implement caching layers
  • Optimize retrieval queries
  • Add memory compression
  • Performance tuning

Phase 5: Document Patterns (1 hour)

  • Create usage documentation
  • Document memory patterns
  • Write integration examples
  • Generate API documentation

Quick Start

import { AgentDB, MemoryManager } from 'agentdb-memory';

// Initialize memory system
const memoryDB = new AgentDB({
  name: 'agent-memory',
  dimensions: 768,
  memory: {
    sessionTTL: 3600,
    consolidationInterval: 300,
    maxSessionSize: 1000
  }
});

const memoryManager = new MemoryManager({
  database: memoryDB,
  layers: ['episodic', 'semantic', 'procedural']
});

// Store memory
await memoryManager.store({
  type: 'episodic',
  content: 'User preferred dark theme',
  context: { userId: '123', timestamp: Date.now() }
});

// Retrieve memory
const memories = await memoryManager.retrieve({
  query: 'user preferences',
  type: 'episodic',
  limit: 10
});

Memory Patterns

Session Memory

const session = await memoryManager.createSession('user-123');
await session.store('conversation', messageHistory);
await session.store('preferences', userPrefs);
const context = await session.getContext();

Long-Term Storage

await memoryManager.consolidate({
  from: 'working-memory',
  to: 'long-term-memory',
  strategy: 'importance-based'
});

Pattern Learning

const patterns = await memoryManager.learnPatterns({
  memory: 'episodic',
  algorithm: 'clustering',
  minSupport: 0.1
});

Success Metrics

  • Memory persists across agent restarts
  • Retrieval latency < 50ms (p95)
  • Pattern recognition accuracy > 85%
  • Context maintained with 95% accuracy
  • Memory consolidation working

MCP Requirements

This skill operates using AgentDB's npm package and API only. No additional MCP servers required.

All AgentDB memory operations are performed through:

  • npm CLI: npx agentdb@latest
  • TypeScript/JavaScript API: import { AgentDB, MemoryManager } from 'agentdb-memory'

Additional Resources

Core Principles

AgentDB Persistent Memory Patterns operates on 3 fundamental principles:

Principle 1: Memory Layering - Separate Short-Term, Working, and Long-Term Storage

Memory systems mirror human cognition by organizing information across distinct temporal layers. Short-term memory handles immediate context (current conversation), working memory maintains active task state, and long-term memory consolidates important patterns for future retrieval.

In practice:

  • Store conversation context in session memory with TTL expiration (1-hour default)
  • Use working memory for active agent tasks and intermediate computation results
  • Consolidate proven patterns and user preferences to long-term storage using importance-based criteria

Principle 2: Pattern Learning - Extract Reusable Knowledge from Episodic Memory

Raw episodic memories (specific events) are valuable but incomplete. True intelligence emerges when systems detect patterns across episodes - recurring user preferences, common error scenarios, effective solution strategies - and encode them as semantic knowledge.

In practice:

  • Run clustering algorithms on episodic memory to identify recurring patterns (min support threshold: 10%)
  • Convert pattern clusters into semantic memory entries with confidence scores
  • Use procedural memory to store proven solution workflows that can be replayed in similar contexts

Principle 3: Performance-First Retrieval - Sub-50ms Latency with HNSW Indexing

Memory systems fail if retrieval is slower than computation. Production AI agents require sub-50ms memory access to maintain real-time responsiveness, necessitating HNSW indexing, quantization, and aggressive caching strategies.

In practice:

  • Build HNSW indexes on all memory stores during initialization (M=16, efConstruction=200)
  • Apply product quantization for 4x memory reduction without accuracy loss
  • Implement LRU caching with 70%+ hit rate for frequently accessed memories

Common Anti-Patterns

Anti-PatternProblemSolution
Memory Hoarder - Store Everything ForeverUnbounded storage growth leads to slow retrieval, high costs, and context pollution. Agents retrieve irrelevant memories from 6 months ago.Implement aggressive TTL policies (1-hour sessions, 30-day working memory, importance-based long-term retention). Use consolidation strategies to compress episodic memories into semantic patterns.
Flat Memory - Single Storage LayerAll memories treated equally creates retrieval chaos. No distinction between current conversation context and learned patterns from last year.Use 3-layer architecture: session (ephemeral), working (task-scoped), long-term (consolidated). Apply different retrieval strategies per layer (recency for session, relevance for semantic).
Retrieval Thrashing - Query Every Memory Store on Every RequestExhaustive searches across all memory layers cause latency spikes (200ms+ retrieval). Agents spend more time remembering than acting.Use cascading retrieval: session first (fastest), semantic second (indexed), episodic last (cold storage). Implement query routing based on memory type and recency. Cache hot paths.

Conclusion

AgentDB Persistent Memory Patterns transforms stateless AI agents into intelligent systems with genuine memory. By implementing layered storage (session, working, long-term), pattern learning algorithms, and performance-optimized retrieval, you enable agents to accumulate knowledge across interactions rather than starting from zero on every request. The 5-phase SOP ensures systematic implementation from architecture design through performance tuning, with success validated through sub-50ms retrieval latency and 95%+ context accuracy.

This skill is essential when building chat systems requiring conversation history, intelligent assistants that learn user preferences over time, or multi-agent systems coordinating through shared memory. The pattern learning capabilities distinguish AgentDB from basic vector databases - instead of merely storing embeddings, it actively extracts reusable knowledge from experience. When agents can remember what worked before, recall user preferences without re-asking, and apply proven patterns to new problems, they transition from tools to true collaborators.

The performance requirements are non-negotiable for production systems. Users abandon agents that "think" for 500ms between responses. By combining HNSW indexing, quantization, and caching strategies, you achieve both intelligent memory and real-time responsiveness - the foundation for AI systems that feel genuinely aware.

GitHub 仓库

DNYoussef/context-cascade
路径: skills/platforms/agentdb-extended/agentdb-persistent-memory-patterns

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

creating-opencode-plugins

该Skill为开发者创建OpenCode插件提供指导,涵盖命令、文件、LSP等25+种事件类型。它详细说明了插件结构、事件API规范及JavaScript/TypeScript实现模式,帮助开发者构建事件驱动的模块。适用于需要拦截操作、扩展功能或自定义AI助手行为的插件开发场景。

查看技能

langchain

LangChain是一个用于构建LLM应用程序的框架,支持智能体、链和RAG应用开发。它提供多模型提供商支持、500+工具集成、记忆管理和向量检索等核心功能。开发者可用它快速构建聊天机器人、问答系统和自主代理,适用于从原型验证到生产部署的全流程。

查看技能

Algorithmic Art Generation

这个Claude Skill帮助开发者使用p5.js创建算法艺术,特别适用于生成式艺术和交互式可视化项目。它支持种子随机性、流场和粒子系统等关键技术,确保艺术作品的重复性和独特性。当讨论生成艺术、算法艺术或计算美学时,该技能会自动激活,指导开发者完成从概念设计到技术实现的全过程。

查看技能