Chuyển đến nội dung
Skillpedia
Agent102k · #825

AgentDB Memory Patterns

Skill này làm gì

Skill này chỉ cách trao cho agent AI bộ nhớ tồn tại qua các phiên, dùng lưu trữ AgentDB. Skill dành cho người xây dựng trợ lý trò chuyện và các agent có trạng thái khác.

Khi nào nên dùng

  • ✓Khi bạn muốn một chatbot nhớ những gì người dùng đã nói trong các cuộc trò chuyện trước.
  • ✓Khi bạn cần một agent giữ ngữ cảnh qua nhiều phiên.
  • ✓Khi bạn đang xây dựng một trợ lý cần học các mẫu từ các tương tác trước đó.

Liên kết skill

https://github.com/ruvnet/RuView/blob/main/.claude/skills/agentdb-memory-patterns/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ruvnet/RuView/blob/main/.claude/skills/agentdb-memory-patterns/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập bộ nhớ cho trợ lý của tôi để nó nhớ sở thích của từng khách hàng lần sau khi họ trò chuyện.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill khởi động một cơ sở dữ liệu AgentDB và lưu chi tiết phiên, ghi chú dài hạn và các mẫu đã học. Khi cần ngữ cảnh cho một cuộc trò chuyện mới, agent sẽ tra cứu những thông tin này.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

AgentDB Memory Patterns

What This Skill Does

Provides memory management patterns for AI agents using AgentDB's persistent storage and ReasoningBank integration. Enables agents to remember conversations, learn from interactions, and maintain context across sessions.

Performance: 150x-12,500x faster than traditional solutions with 100% backward compatibility.

Prerequisites

  • Node.js 18+
  • AgentDB v1.0.7+ (via agentic-flow or standalone)
  • Understanding of agent architectures

Quick Start with CLI

Initialize AgentDB

# Initialize vector database
npx agentdb@latest init ./agents.db

# Or with custom dimensions
npx agentdb@latest init ./agents.db --dimension 768

# Use preset configurations
npx agentdb@latest init ./agents.db --preset large

# In-memory database for testing
npx agentdb@latest init ./memory.db --in-memory

Start MCP Server for Claude Code

# Start MCP server (integrates with Claude Code)
npx agentdb@latest mcp

# Add to Claude Code (one-time setup)
claude mcp add agentdb npx agentdb@latest mcp

Create Learning Plugin

# Interactive plugin wizard
npx agentdb@latest create-plugin

# Use template directly
npx agentdb@latest create-plugin -t decision-transformer -n my-agent

# Available templates:
# - decision-transformer (sequence modeling RL)
# - q-learning (value-based learning)
# - sarsa (on-policy TD learning)
# - actor-critic (policy gradient)
# - curiosity-driven (exploration-based)

Quick Start with API

import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';

// Initialize with default configuration
const adapter = await createAgentDBAdapter({
  dbPath: '.agentdb/reasoningbank.db',
  enableLearning: true,      // Enable learning plugins
  enableReasoning: true,      // Enable reasoning agents
  quantizationType: 'scalar', // binary | scalar | product | none
  cacheSize: 1000,            // In-memory cache
});

// Store interaction memory
const patternId = await adapter.insertPattern({
  id: '',
  type: 'pattern',
  domain: 'conversation',
  pattern_data: JSON.stringify({
    embedding: await computeEmbedding('What is the capital of France?'),
    pattern: {
      user: 'What is the capital of France?',
      assistant: 'The capital of France is Paris.',
      timestamp: Date.now()
    }
  }),
  confidence: 0.95,
  usage_count: 1,
  success_count: 1,
  created_at: Date.now(),
  last_used: Date.now(),
});

// Retrieve context with reasoning
const context = await adapter.retrieveWithReasoning(queryEmbedding, {
  domain: 'conversation',
  k: 10,
  useMMR: true,              // Maximal Marginal Relevance
  synthesizeContext: true,    // Generate rich context
});

Memory Patterns

1. Session Memory

class SessionMemory {
  async storeMessage(role: string, content: string) {
    return await db.storeMemory({
      sessionId: this.sessionId,
      role,
      content,
      timestamp: Date.now()
    });
  }

  async getSessionHistory(limit = 20) {
    return await db.query({
      filters: { sessionId: this.sessionId },
      orderBy: 'timestamp',
      limit
    });
  }
}

2. Long-Term Memory

// Store important facts
await db.storeFact({
  category: 'user_preference',
  key: 'language',
  value: 'English',
  confidence: 1.0,
  source: 'explicit'
});

// Retrieve facts
const prefs = await db.getFacts({
  category: 'user_preference'
});

3. Pattern Learning

// Learn from successful interactions
await db.storePattern({
  trigger: 'user_asks_time',
  response: 'provide_formatted_time',
  success: true,
  context: { timezone: 'UTC' }
});

// Apply learned patterns
const pattern = await db.matchPattern(currentContext);

Advanced Patterns

Hierarchical Memory

// Organize memory in hierarchy
await memory.organize({
  immediate: recentMessages,    // Last 10 messages
  shortTerm: sessionContext,    // Current session
  longTerm: importantFacts,     // Persistent facts
  semantic: embeddedKnowledge   // Vector search
});

Memory Consolidation

// Periodically consolidate memories
await memory.consolidate({
  strategy: 'importance',       // Keep important memories
  maxSize: 10000,              // Size limit
  minScore: 0.5                // Relevance threshold
});

CLI Operations

Query Database

# Query with vector embedding
npx agentdb@latest query ./agents.db "[0.1,0.2,0.3,...]"

# Top-k 
Câu hỏi thường gặp

Bộ nhớ được lưu ở đâu?

Trong một file cơ sở dữ liệu AgentDB. Có thêm tùy chọn lưu trong bộ nhớ tạm để thử nghiệm.

Nó có kết nối được với Claude Code không?

Có. Skill chỉ cách khởi động máy chủ MCP của AgentDB và thêm vào Claude Code.

Cần chuẩn bị gì trước khi bắt đầu?

Node.js 18 trở lên và AgentDB phiên bản 1.0.7 trở lên.

Chi tiết

Mô tả gốc của tác giả

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

repo: ruvnet/RuView

Độ phổ biến

Sao GitHub
102k
Vị trí xếp hạng
#825
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự