β‘ FusionPact
The Agent-Native Retrieval Engine
Hybrid Vector + Reasoning + Memory for AI Agents

Similarity β Relevance. FusionPact is the first retrieval engine that combines HNSW vector search, reasoning-based tree retrieval, and agent memory in a single platform β purpose-built for AI agents and multi-agent systems.
Quickstart Β· Hybrid Retrieval Β· Agent Memory Β· Multi-Agent Β· MCP Server Β· Tree Index Β· RAG Pipeline Β· API Reference Β· Benchmarks Β· Contributing
Why FusionPact?
Traditional vector databases retrieve what's similar. But similar β relevant. Ask a vector DB for "Q3 2024 revenue" and you might get Q2 or Q4 data β semantically similar, but the wrong answer.
FusionPact solves this by combining three retrieval paradigms:
| Strategy | How It Works | Best For |
|---|
| Vector Search (HNSW) | Embedding similarity, O(log N) | Broad search across large collections |
| Tree Reasoning | LLM navigates document structure | Precise retrieval in structured documents |
| Keyword Search (BM25) | Term frequency matching | Exact match requirements |
Plus purpose-built agent memory, multi-agent orchestration, and MCP server β all zero-dependency, local-first, and free.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FusionPact Retrieval Engine β
β β
β ββββββββββββββ βββββββββββββββ ββββββββββββββββββ β
β β Vector β β Tree β β Keyword β β
β β (HNSW) β β (Reasoning) β β (BM25) β β
β βββββββ¬βββββββ ββββββββ¬βββββββ βββββββββ¬βββββββββ β
β ββββββββββββββ¬βββββ΄ββββββββββββββββββ β
β βΌ β
β Reciprocal Rank Fusion β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Agent Memory (Multi-Agent) β β
β β Episodic β Semantic β Procedural β Shared β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β MCP Server (Claude, Cursor, etc.) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β‘ Quickstart
# Install
npm install fusionpact
# Run the demo
npx fusionpact demo
# Start HTTP + MCP server
npx fusionpact serve --port 8080
# Start MCP server for Claude Desktop
npx fusionpact mcp
10 Lines of Code
const { create } = require('fusionpact');
const fp = create({ embedder: 'ollama' }); // or 'mock' for zero-config
// Ingest a document β auto-chunks, embeds, indexes
await fp.rag.ingest('Your document text here...', { source: 'doc.pdf' });
// Hybrid search β vector + reasoning + keyword, fused automatically
const results = await fp.retriever.retrieve('What safety protocols exist?', {
collection: 'default',
strategy: 'hybrid'
});
// Or build LLM-ready context directly
const context = await fp.rag.buildContext('What safety protocols exist?');
console.log(context.prompt); // Ready to paste into any LLM
π Hybrid Retrieval Engine
The core differentiator: a single API that intelligently routes queries through multiple retrieval strategies and fuses results using Reciprocal Rank Fusion.
const { create } = require('fusionpact');
const fp = create({
embedder: 'ollama', // Local, free, private
llmProvider: 'ollama', // For tree reasoning
enableHybrid: true
});
// Index a structured document with tree structure
await fp.treeIndex.indexDocument('annual-report', reportText, {
format: 'markdown'
});
// Hybrid retrieval β automatically uses the best strategy
const results = await fp.retriever.retrieve(
'What were the total deferred tax assets in Q3?',
{
collection: 'documents', // Vector search here
docId: 'annual-report', // Tree reasoning here
topK: 5,
strategy: 'hybrid' // Fuse all strategies
}
);
// Each result includes:
// - score: Fused relevance score
// - content: Retrieved text
// - sources: Which strategies contributed { vector: 0.8, tree: 0.9, keyword: 0.3 }
// - citation: "Section 3 > Financial Data > Table 3.2.1"
// - reasoning: Full tree traversal reasoning trace
Strategy Weights
const retriever = new HybridRetriever({
engine, treeIndex, embedder,
weights: {
vector: 0.4, // 40% weight to vector similarity
tree: 0.4, // 40% weight to reasoning-based retrieval
keyword: 0.2 // 20% weight to keyword matching
}
});
Adaptive Learning
FusionPact learns which retrieval strategy works best for different query patterns:
// Record feedback on result quality
retriever.recordFeedback('financial query', 'tree', 0.95);
retriever.recordFeedback('general search', 'vector', 0.85);
// Get recommended weights for a new query
const weights = retriever.getAdaptiveWeights('new financial query');
// β { vector: 0.25, tree: 0.6, keyword: 0.15 }
π² Tree Index
Reasoning-based retrieval for structured documents. Builds a hierarchical tree (like an intelligent table of contents) and uses LLM reasoning to navigate to the most relevant sections.
const { TreeIndex, LLMProvider } = require('fusionpact');
const llm = new LLMProvider({ provider: 'ollama' }); // Free, local
const tree = new TreeIndex({ llmProvider: llm });
// Index a document
await tree.indexDocument('sec-filing', filingText, {
format: 'markdown',
metadata: { source: '10-K', year: 2024 }
});
// Reasoning-based search
const results = await tree.search('sec-filing', 'Total deferred tax assets', {
maxResults: 3,
includeReasoning: true
});
// results[0]:
// {
// content: "Table 5.2: Deferred Tax Assets...",
// relevanceScore: 0.95,
// citation: "Financial Statements > Note 5 > Tax Assets > Table 5.2",
// reasoningPath: [
// { title: "Financial Statements", reasoning: "Deferred tax assets are in financial notes", action: "explore" },
// { title: "Note 5: Income Taxes", reasoning: "This note covers tax-related assets", action: "explore" },
// { title: "Table 5.2", reasoning: "Contains the deferred tax asset breakdown", action: "retrieve" }
// ]
// }
Works Without LLM Too
If no LLM provider is configured, TreeIndex falls back to keyword-based tree traversal β still useful, just without the reasoning path:
const tree = new TreeIndex(); // No LLM β keyword fallback
await tree.indexDocument('doc', text, { format: 'markdown' });
const results = await tree.search('doc', 'safety protocols');
π§ Agent Memory
Purpose-built memory system for AI agents with four memory types:
| Memory Type | What It Stores | Example |
|---|
| Episodic | Events, conversations, observations | "User asked about Lab B chemical storage" |
| Semantic | Facts, domain knowledge, learned info | "OSHA 1910.106 covers flammable liquids" |
| Procedural | Tool schemas, API specs, workflows | search_incidents tool definition |
| Shared | Cross-agent knowledge pool | "Customer ACME prefers ISO 14001" |
const { create } = require('fusionpact');
const fp = create({ embedder: 'ollama', enableMemory: true });
// Episodic β remember what happened
await fp.memory.remember('agent-1', {
content: 'User prefers dark mode and concise answers',
role: 'system',
importance: 0.8
});
// Semantic β learn knowledge
await fp.memory.learn('agent-1',
'OSHA 29 CFR 1910 covers general industry safety standards.',
{ source: 'regulations', category: 'compliance' }
);
// Procedural β register tools
await fp.memory.registerTool('agent-1', {
name: 'search_incidents',
description: 'Search EHS incident reports by category and severity',
schema: { type: 'object', properties: { severity: { type: 'string' } } }
});
// Recall β cross-memory search
const memories = await fp.memory.recall('agent-1', 'safety compliance');
// β { episodic: [...], semantic: [...], procedural: [...], shared: [...] }
// Conversation memory
fp.memory.addMessage('agent-1', 'thread-001', { role: 'user', content: 'What are the PPE requirements?' });
fp.memory.addMessage('agent-1', 'thread-001', { role: 'assistant', content: 'PPE requirements include...' });
const history = fp.memory.getConversation('agent-1', 'thread-001');
// GDPR-friendly forget
fp.memory.forget('agent-1', { type: 'all' });
π€ Multi-Agent Orchestration
Coordinate multiple AI agents with isolated memory, shared knowledge, and message routing:
const { create, AgentOrchestrator } = require('fusionpact');
const fp = create({ embedder: 'ollama', enableMemory: true });
const orchestrator = new AgentOrchestrator({
engine: fp.engine,
memory: fp.memory,
retriever: fp.retriever
});
// Register agents
orchestrator.registerAgent({
agentId: 'researcher',
name: 'Research Agent',
role: 'Find and analyze information',
capabilities: ['search', 'analysis', 'summarization']
});
orchestrator.registerAgent({
agentId: 'writer',
name: 'Writing Agent',
role: 'Generate reports and documentation',
capabilities: ['writing', 'formatting', 'editing']
});