agentdb-patterns
Memory persistence, vector search, optimization, and learning patterns for AI agents. Use when implementing persistent memory, vector-based search, agent state management, or building learning systems that improve over time.
- License 许可
- MIT
- 最近更新
- 2026-05-18
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- agentdb-patterns
- description
- Memory persistence, vector search, optimization, and learning patterns for AI agents. Use when implementing persistent memory, vector-based search, agent state management, or building learning systems that improve over time.
03 SKILL.md 正文
AgentDB Patterns
Memory persistence, vector search, optimization, and learning patterns for AI agent systems.
Memory Patterns
Memory Types
- Ephemeral — Current session only, fast access (Zustand store)
- Persistent — Survives sessions, database-backed (Supabase)
- Shared — Accessible across agents (coordination memory)
- Private — Agent-specific, isolated context
Memory Hierarchy
L1: In-memory cache (Zustand) — <1ms access
L2: Local storage/IndexedDB — <10ms access
L3: Supabase PostgreSQL — <50ms access
L4: External APIs (OpenRouter context) — <500ms access
Memory Operations
- Store — Save with key, value, type, optional TTL
- Retrieve — Get by exact key
- Search — Pattern-based search (prefix, regex)
- Associate — Link related memories (e.g., "auth" ↔ "jwt" ↔ "refresh-token")
- Consolidate — Merge duplicate/related entries
- Prune — Remove expired or low-value entries
Vector Search Patterns
Embedding-Based Search
Use vector embeddings for semantic similarity:
- Convert text to embeddings (OpenAI/Supabase pgvector)
- Store embeddings alongside content
- Query with cosine similarity
- Filter by metadata (type, date, confidence)
Search Strategies
- Exact Match — Key-based lookup, fastest
- Prefix Search — Namespace-based, good for hierarchical data
- Semantic Search — Vector similarity, best for natural language queries
- Hybrid — Combine exact + semantic for best results
Supabase pgvector Integration
-- Enable vector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Add embedding column
ALTER TABLE knowledge_base ADD COLUMN embedding vector(1536);
-- Create index for fast similarity search
CREATE INDEX ON knowledge_base USING ivfflat (embedding vector_cosine_ops);
-- Query similar items
SELECT *, 1 - (embedding <=> query_embedding) as similarity
FROM knowledge_base
ORDER BY embedding <=> query_embedding
LIMIT 10;
Optimization Patterns
Cache Strategies
- LRU Cache — Evict least recently used entries
- TTL Cache — Time-based expiration
- Write-Through — Update cache and database simultaneously
- Write-Behind — Buffer writes, batch to database
Query Optimization
- Prepared statements for common queries
- Connection pooling for database access
- Batch operations for bulk inserts/updates
- Pagination for large result sets
Memory Pressure Handling
- Monitor memory usage thresholds
- Auto-evict low-priority entries
- Compress old data
- Archive to cold storage
Learning Patterns
Trajectory-Based Learning
Record operations → Analyze outcomes → Discover patterns → Suggest improvements.
Feedback Loop
Action → Outcome → Score → Store → Analyze → Improve → Action (better)
Knowledge Accumulation
- Store successful patterns with confidence scores
- Track failure modes and recovery strategies
- Build knowledge graphs linking related concepts
- Prune outdated or contradicted knowledge
Aurion AgentDB Integration
Credit System Memory
user_credits table:
- balance (atomic deduction)
- monthly_allowance (plan-based)
- period_start/period_end (lazy reset)
- bonus_credits (one-time additions)
Memory pattern: Cache user credits in React Query, invalidate on deduction
Tool Session Memory
Each of 11 tools maintains session state:
- Chat history (chat tool)
- File tree (IDE, 1code)
- Canvas state (ai-marketing)
- Editor content (text-editor, code-editor)
Memory pattern: Supabase Realtime for sync, local buffer for offline
Research Memory
Research results from Tavily/Exa/Brave:
- Store in .research/latest.json
- TTL: 24 hours
- Key: topic + source hash
- Inject into LLM context automatically
Best Practices
- Use appropriate memory tier for access pattern
- Set TTLs on all non-permanent entries
- Index frequently queried fields
- Batch writes to reduce database round-trips
- Monitor memory pressure and cache hit rates
- Prune old data regularly
- Use vector search for semantic queries, exact search for known keys
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vercel-react-view-transitions
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
vercel-cli-with-tokens
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".