@parthivpandya/agent-fabric
v0.1.0
Published
Shared memory layer for multi-agent AI systems. Let your agents remember, recall, and coordinate — without stepping on each other.
Maintainers
Readme
agent-fabric
Shared memory layer for multi-agent AI systems.
Let your agents remember, recall, and coordinate — without stepping on each other. agent-fabric is a production-ready, feature-rich memory engine designed to compete directly with frameworks like Mem0, Zep, and Letta.
┌─────────────────────────────────────────────────────────┐
│ agent-fabric (npm) │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ MEMORY STORE │ │ EVENT BUS │ │CONFLICT CHECK│ │
│ │ (plug any DB)│ │ (real-time │ │ (blocks bad │ │
│ │ Redis/SQLite │ │ sync) │ │ actions) │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │
│ ┌──────▼─────────────────▼──────────────────▼───────┐ │
│ │ AGENT FABRIC CORE │ │
│ │ register() · remember() · recall() · forget() │ │
│ └───────────────────────┬───────────────────────────┘ │
│ │ │
└──────────────────────────┼──────────────────────────────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
📧 Email Agent 💬 CRM Agent 📦 Support Agent
(LangChain) (Custom code) (n8n webhook)Quick Start
import { AgentFabric } from 'agent-fabric';
const fabric = new AgentFabric();
const agent = fabric.registerAgent('email-agent');
await agent.remember({ entity: 'acme', fact: 'Sent welcome email' });That's it. Three lines.
Install
npm install agent-fabricFeatures
- 🧠 Shared Memory & Scopes — Global, user, session, and agent-level memory boundaries.
- 🔍 Pluggable Vector Embeddings — Local zero-config TF hashing by default. Pluggable support for OpenAI (
text-embedding-3-small), Cohere, Ollama, etc. - ⚡ Real-time Sync — Agents are notified instantly when memories change via
EventEmitter(local) or Redis Pub/Sub (multi-server). - 🛡️ Conflict Detection — Prevent agents from contradicting each other using blocking intents.
- 🕸️ Knowledge Graph — Extract entity relationships (
CEO_OF,WORKS_AT) and traverse multi-hop paths. - ⏱️ Temporal Memory — Facts have
validFromandvalidTodates. Query historical data with point-in-timeasOfqueries. - 🧹 Deduplication Engine — Automatically supersedes old facts when highly similar new facts arrive. Prevents "stale fact pollution".
- 🔌 4 Storage Backends — Memory, SQLite (default), Redis, PostgreSQL.
- 🤖 MCP Server Mode — Instantly spin up a Model Context Protocol server to expose memory tools to Claude Code, Cursor, and Windsurf.
- 📊 Observability Dashboard — Track memory counts, deduplication skips, conflicts, and recall latencies.
Advanced Usage
Memory Deduplication
The built-in DeduplicationEngine detects when an agent writes a fact that contradicts or supersedes an older fact.
await agent.remember({ entity: 'acme-corp', fact: 'Headquarters is in San Francisco' });
// Later...
await agent.remember({ entity: 'acme-corp', fact: 'Headquarters moved to New York City' });
// Recalling will automatically return the NEW fact only.
const result = await agent.recall({ entity: 'acme-corp' });Knowledge Graph
Agents can explicitly store and traverse entity relationships.
await agent.remember({
entity: 'john',
fact: 'John was hired as CEO of Acme Corp',
relationships: [
{ from: 'john', relation: 'CEO_OF', to: 'acme-corp' }
]
});
// Multi-hop pathfinding
const path = fabric.getGraph().findPath('john', 'acme-corp');Temporal Point-In-Time Queries
Reason about what was true in the past.
await agent.remember({
entity: 'john',
fact: 'Works at Google',
validFrom: new Date('2020-01-01'),
validTo: new Date('2024-06-15'),
});
await agent.remember({
entity: 'john',
fact: 'Works at Anthropic',
validFrom: new Date('2024-07-01'),
});
// Query as of 2022
const pastResult = await agent.recall({ entity: 'john', asOf: new Date('2022-01-01') });MCP Server Mode
Enable AI assistants (like Claude) to natively use agent-fabric.
await fabric.startMCPServer({ defaultAgentId: 'claude' });
// Claude now has access to tools: remember, recall, check_conflict, forget, get_briefLLM Fact Extraction
Don't want to manually call remember()? Pipe raw conversation logs directly to an LLM provider to extract facts and relationships automatically.
// 1. Configure the LLM
const fabric = new AgentFabric({
llm: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY }
});
// 2. Ingest raw conversations
await agent.ingest([
{ role: 'user', content: 'Hi, I am John, CEO of Acme Corp.' }
]);
// Auto-extracts: John is CEO of Acme Corp, and links the entities!Framework Integrations
Inject agent-fabric natively into popular multi-agent orchestrators with 1-line tool wrappers:
// LangChain integration
import { createAgentTools } from 'agent-fabric/integrations/langchain';
const tools = createAgentTools(agent); // Returns DynamicTool schemas
// Vercel AI SDK integration
import { agentFabricVercelTools } from 'agent-fabric/integrations/vercel';
const result = await generateText({
model: openai('gpt-4o'),
tools: agentFabricVercelTools(agent)
});GDPR & Compliance
Securely wipe or export all traces of an entity from the database and knowledge graph.
await fabric.gdprDelete('user-123'); // Wipes all memories and relationships
const data = await fabric.gdprExport('user-123'); // Returns full JSON dumpCLI Tool
Interact with the memory engine directly from your terminal!
npx agent-fabric recall --entity acme-corp
npx agent-fabric brief acme-corp
npx agent-fabric agents
npx agent-fabric serve --port 3000 # Start the webhook bridgeAPI Reference
AgentFabric
const fabric = new AgentFabric({
store: 'sqlite', // 'memory' | 'sqlite' | 'redis' | 'postgres'
dbPath: './my-fabric.db', // SQLite file path
conflictWindowDays: 7, // How far back to check for conflicts
enableEmbeddings: true, // Enable semantic search
enableDeduplication: true, // Automatically deduplicate/update facts
deduplicationThreshold: 0.85,// Threshold for semantic superseding
embedding: {
provider: 'openai', // Use OpenAI instead of local hashing
apiKey: process.env.OPENAI_API_KEY
}
});fabric.registerAgent(id, config?)
Register a new agent with the fabric.
const agent = fabric.registerAgent('crm-agent', {
name: 'CRM Agent',
permissions: {
canWrite: true,
canReadOthers: true,
canDelete: false,
allowedEntityTypes: ['company', 'lead'],
},
});fabric.getBrief(entity)
Get a structured summary of everything known about an entity, including graph relationships.
const brief = await fabric.getBrief('acme-corp');
// { entity, totalMemories, byAgent, allTags, relationships, activeIntents, ... }Agent
agent.remember(input)
Save a fact about an entity.
await agent.remember({
entity: 'acme-corp',
entityType: 'company',
fact: 'Sent welcome email',
intent: 'onboarding',
scope: 'global', // 'global' | 'session' | 'user' | 'agent'
importance: 0.9, // Weight for recall sorting
});agent.recall(options?)
Query memories by entity, semantic search, tags, or time.
// By entity
const result = await agent.recall({ entity: 'acme-corp' });
// By semantic search
const result = await agent.recall({
query: 'customer complaints about billing',
minSimilarity: 0.3,
});
// Point-in-time
const past = await agent.recall({ asOf: new Date('2023-01-01') });agent.checkConflict(input)
Check if a planned action conflicts with existing memories.
const check = await agent.checkConflict({
entity: 'acme-corp',
plannedAction: 'send-promotional-email',
tags: ['marketing'],
});
if (!check.allowed) {
console.log('Blocked:', check.reason);
console.log('Suggestion:', check.suggestion);
}Storage Backends
| Backend | Use Case | Config |
|------------|-----------------------------|---------------------------------|
| memory | Testing, prototyping | { store: 'memory' } |
| sqlite | Local development (default) | { store: 'sqlite' } |
| redis | Multi-server production | { store: 'redis', connection: 'redis://...' } |
| postgres | Enterprise + audit logs | { store: 'postgres', connection: 'postgresql://...' } |
Auto-detection: Set AGENT_FABRIC_URL=redis://... and the Redis adapter is used automatically.
License
MIT
