$npx -y skills add spencermarx/open-code-review --skill agentdb-advancedMaster advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration. Use when building distributed AI systems, multi-agent coordination, or advanced vector search applications.
| 1 | # AgentDB Advanced Features |
| 2 | |
| 3 | ## What This Skill Does |
| 4 | |
| 5 | Covers advanced AgentDB capabilities for distributed systems, multi-database coordination, custom distance metrics, hybrid search (vector + metadata), QUIC synchronization, and production deployment patterns. Enables building sophisticated AI systems with sub-millisecond cross-node communication and advanced search capabilities. |
| 6 | |
| 7 | **Performance**: <1ms QUIC sync, hybrid search with filters, custom distance metrics. |
| 8 | |
| 9 | ## Prerequisites |
| 10 | |
| 11 | - Node.js 18+ |
| 12 | - AgentDB v1.0.7+ (via agentic-flow) |
| 13 | - Understanding of distributed systems (for QUIC sync) |
| 14 | - Vector search fundamentals |
| 15 | |
| 16 | --- |
| 17 | |
| 18 | ## QUIC Synchronization |
| 19 | |
| 20 | ### What is QUIC Sync? |
| 21 | |
| 22 | QUIC (Quick UDP Internet Connections) enables sub-millisecond latency synchronization between AgentDB instances across network boundaries with automatic retry, multiplexing, and encryption. |
| 23 | |
| 24 | **Benefits**: |
| 25 | - <1ms latency between nodes |
| 26 | - Multiplexed streams (multiple operations simultaneously) |
| 27 | - Built-in encryption (TLS 1.3) |
| 28 | - Automatic retry and recovery |
| 29 | - Event-based broadcasting |
| 30 | |
| 31 | ### Enable QUIC Sync |
| 32 | |
| 33 | ```typescript |
| 34 | import { createAgentDBAdapter } from 'agentic-flow/reasoningbank'; |
| 35 | |
| 36 | // Initialize with QUIC synchronization |
| 37 | const adapter = await createAgentDBAdapter({ |
| 38 | dbPath: '.agentdb/distributed.db', |
| 39 | enableQUICSync: true, |
| 40 | syncPort: 4433, |
| 41 | syncPeers: [ |
| 42 | '192.168.1.10:4433', |
| 43 | '192.168.1.11:4433', |
| 44 | '192.168.1.12:4433', |
| 45 | ], |
| 46 | }); |
| 47 | |
| 48 | // Patterns automatically sync across all peers |
| 49 | await adapter.insertPattern({ |
| 50 | // ... pattern data |
| 51 | }); |
| 52 | |
| 53 | // Available on all peers within ~1ms |
| 54 | ``` |
| 55 | |
| 56 | ### QUIC Configuration |
| 57 | |
| 58 | ```typescript |
| 59 | const adapter = await createAgentDBAdapter({ |
| 60 | enableQUICSync: true, |
| 61 | syncPort: 4433, // QUIC server port |
| 62 | syncPeers: ['host1:4433'], // Peer addresses |
| 63 | syncInterval: 1000, // Sync interval (ms) |
| 64 | syncBatchSize: 100, // Patterns per batch |
| 65 | maxRetries: 3, // Retry failed syncs |
| 66 | compression: true, // Enable compression |
| 67 | }); |
| 68 | ``` |
| 69 | |
| 70 | ### Multi-Node Deployment |
| 71 | |
| 72 | ```bash |
| 73 | # Node 1 (192.168.1.10) |
| 74 | AGENTDB_QUIC_SYNC=true \ |
| 75 | AGENTDB_QUIC_PORT=4433 \ |
| 76 | AGENTDB_QUIC_PEERS=192.168.1.11:4433,192.168.1.12:4433 \ |
| 77 | node server.js |
| 78 | |
| 79 | # Node 2 (192.168.1.11) |
| 80 | AGENTDB_QUIC_SYNC=true \ |
| 81 | AGENTDB_QUIC_PORT=4433 \ |
| 82 | AGENTDB_QUIC_PEERS=192.168.1.10:4433,192.168.1.12:4433 \ |
| 83 | node server.js |
| 84 | |
| 85 | # Node 3 (192.168.1.12) |
| 86 | AGENTDB_QUIC_SYNC=true \ |
| 87 | AGENTDB_QUIC_PORT=4433 \ |
| 88 | AGENTDB_QUIC_PEERS=192.168.1.10:4433,192.168.1.11:4433 \ |
| 89 | node server.js |
| 90 | ``` |
| 91 | |
| 92 | --- |
| 93 | |
| 94 | ## Distance Metrics |
| 95 | |
| 96 | ### Cosine Similarity (Default) |
| 97 | |
| 98 | Best for normalized vectors, semantic similarity: |
| 99 | |
| 100 | ```bash |
| 101 | # CLI |
| 102 | npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m cosine |
| 103 | |
| 104 | # API |
| 105 | const result = await adapter.retrieveWithReasoning(queryEmbedding, { |
| 106 | metric: 'cosine', |
| 107 | k: 10, |
| 108 | }); |
| 109 | ``` |
| 110 | |
| 111 | **Use Cases**: |
| 112 | - Text embeddings (BERT, GPT, etc.) |
| 113 | - Semantic search |
| 114 | - Document similarity |
| 115 | - Most general-purpose applications |
| 116 | |
| 117 | **Formula**: `cos(θ) = (A · B) / (||A|| × ||B||)` |
| 118 | **Range**: [-1, 1] (1 = identical, -1 = opposite) |
| 119 | |
| 120 | ### Euclidean Distance (L2) |
| 121 | |
| 122 | Best for spatial data, geometric similarity: |
| 123 | |
| 124 | ```bash |
| 125 | # CLI |
| 126 | npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m euclidean |
| 127 | |
| 128 | # API |
| 129 | const result = await adapter.retrieveWithReasoning(queryEmbedding, { |
| 130 | metric: 'euclidean', |
| 131 | k: 10, |
| 132 | }); |
| 133 | ``` |
| 134 | |
| 135 | **Use Cases**: |
| 136 | - Image embeddings |
| 137 | - Spatial data |
| 138 | - Computer vision |
| 139 | - When vector magnitude matters |
| 140 | |
| 141 | **Formula**: `d = √(Σ(ai - bi)²)` |
| 142 | **Range**: [0, ∞] (0 = identical, ∞ = very different) |
| 143 | |
| 144 | ### Dot Product |
| 145 | |
| 146 | Best for pre-normalized vectors, fast computation: |
| 147 | |
| 148 | ```bash |
| 149 | # CLI |
| 150 | npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m dot |
| 151 | |
| 152 | # API |
| 153 | const result = await adapter.retrieveWithReasoning(queryEmbedding, { |
| 154 | metric: 'dot', |
| 155 | k: 10, |
| 156 | }); |
| 157 | ``` |
| 158 | |
| 159 | **Use Cases**: |
| 160 | - Pre-normalized embeddings |
| 161 | - Fast similarity computation |
| 162 | - When vectors are already unit-length |
| 163 | |
| 164 | **Formula**: `dot = Σ(ai × bi)` |
| 165 | **Range**: [-∞, ∞] (higher = more similar) |
| 166 | |
| 167 | ### Custom Distance Metrics |
| 168 | |
| 169 | ```typescript |
| 170 | // Implement custom distance function |
| 171 | function customDistance(vec1: number[], vec2: number[]): number { |
| 172 | // Weighted Euclidean distance |
| 173 | const weights = [1.0, 2.0, 1.5, ...]; |
| 174 | let sum = 0; |
| 175 | for (let i = 0; i < vec1.length; i++) { |
| 176 | sum += weights[i] * Math.pow(vec1[i] - vec2[i], 2); |
| 177 | } |
| 178 | return Math.sqrt(sum); |
| 179 | } |
| 180 | |
| 181 | // Use in search (requires custom implementation) |
| 182 | ``` |
| 183 | |
| 184 | --- |
| 185 | |
| 186 | ## Hybrid Search (Vector + Metadata) |
| 187 | |
| 188 | ### Basic Hybrid Search |
| 189 | |
| 190 | Combine vector similarity with metadata filtering: |
| 191 | |
| 192 | ```typescript |
| 193 | // Store documents with metadata |
| 194 | await adapter.insertPattern({ |
| 195 | id: '', |
| 196 | type: 'document', |
| 197 | domain: 'research-papers', |
| 198 | pattern_data: JSON.stringify({ |
| 199 | embedding: documentEmbeddi |