{
  "markdown": "<h1 align=\"center\">SMRITI Memcore</h1>\n\n<p align=\"center\">\n  <strong>Enterprise-grade, privacy-first Long-Term Memory (LTM) engine for LLM agents, multi-agent frameworks, and MCP clients.</strong>\n</p>\n\n<p align=\"center\">\n  🌐 <a href=\"https://www.smriti-memcore.com\"><strong>www.smriti-memcore.com</strong></a>\n</p>\n\n[![PyPI](https://img.shields.io/pypi/v/smriti-memcore.svg)](https://pypi.org/project/smriti-memcore/)\n[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n[![Website](https://img.shields.io/badge/website-smriti--memcore.com-c5a059?style=flat&logo=vercel)](https://www.smriti-memcore.com)\n\n<!-- mcp-name: io.github.shivamtyagi18/smriti-memory -->\n\n---\n\n## 💡 What is SMRITI?\n\nSMRITI is a high-performance, neuro-inspired long-term memory layer designed to give AI agents persistent, adaptive recall without blocking their real-time execution loop. \n\nInspired by human Dual-Process cognitive theory, SMRITI splits memory operations into:\n1. **System 1 (Immediate Heuristics)**: Decoupled, millisecond-level ingestion of raw interactions into an append-only Episode Buffer.\n2. **System 2 (Async Consolidation)**: Background LLM-driven consolidation that extracts knowledge graphs, resolves contradictions, identifies skills, and decays weak memories.\n\n---\n\n## ⚔️ SMRITI vs. Naive RAG & Vector Databases\n\n| Feature | Naive RAG / Vector DBs | SMRITI Memory Engine |\n|---|---|---|\n| **Latency** | Scales linearly with context size; blocks agent loops | **Sub-5ms ingestion** (System 1); System 2 is asynchronous |\n| **Context Window** | Stuffs raw logs, leading to prompt bloat and distraction | **Miller's Law (7 ± 2 slots)** capacity-bounded Working Memory |\n| **Data Evolution** | Static embeddings; struggles with contradictions/corrections | **Automatic conflict resolution**, abstraction, and temporal decay |\n| **Relationships** | Flat vector search; no concept of entity links | **Semantic Palace Graph** showing structured Room/Topic associations |\n| **Privacy & Sync** | All-or-nothing storage; complex namespace routing | **Private Rooms** and `private=True` tags natively isolating user syncs |\n\n---\n\n## 🚀 Key Capabilities\n\n*   🧠 **Dual-Process Performance**: Zero-blocking real-time loops. Write immediately, analyze when idle.\n*   🔒 **Privacy-First (Private Rooms)**: Create local semantic rooms whose memories are automatically excluded from shared/team-wide sync.\n*   🔌 **Model Context Protocol (MCP)**: Native MCP server integration with Claude Code, Claude Desktop, Gemini Antigravity, and Codex.\n*   📦 **AMP v1.0 Spec Compliant**: Drop-in compatibility with any agent framework conforming to the Agent Memory Protocol.\n*   📊 **Visual Graph Explorer**: Clean D3.js-based visualization interface with Prometheus metrics monitoring.\n*   📂 **Obsidian Vault Integration**: Automatically syncs your agent's memory graph into an Obsidian vault for human curation.\n*   🧩 **Framework Agnostic**: Integrates natively with LangChain, LlamaIndex, CrewAI, and AutoGen.\n\n---\n\n## 🧠 Core Architecture\n\n```text\n                           ┌─────────────────────────────────┐\n                           │    Asynchronous Consolidation   │\n                           │      (8 Background Processes)   │\n                           │  • Chunking      • Cross-Ref.   │\n                           │  • Conflict Res. • Skill Ext.   │\n                           │  • Forgetting    • Spaced Rep.  │\n                           │  • Reflection    • Defragment.  │\n                           └────────────────┬────────────────┘\n                                            │ background\n  ┌──────────┐   ┌──────────┐   ┌───────────▼─────────┐   ┌──────────┐\n  │  Input   │──▶│ Attention │──▶│   Episode Buffer    │──▶│ Semantic │\n  │  Text    │   │   Gate    │   │  (append-only log)  │   │  Palace  │\n  │  └───────┘   │ (salience │   └─────────────────────┘   │  Graph   │\n  │              │  filter)  │                              │ G=(V,E)  │\n  └──────────┘   └──────────┘                              └────┬─────┘\n                                                                │\n  ┌──────────┐   ┌──────────┐   ┌───────────────────┐           │\n  │  Query   │──▶│ Retrieval│──▶│  Working Memory   │◀──────────┘\n  │          │   │  Engine  │   │   (7 ± 2 slots)   │\n  └──────────┘   │ Q(v) =   │   └───────────────────┘\n                 │ β₁cos +  │\n                 │ β₂decay+ │   ┌───────────────────┐\n                 │ β₃freq + │──▶│    Meta-Memory    │\n                 │ β₄sal    │   │ (confidence map)  │\n                 └──────────┘   └───────────────────┘\n```\n\n---\n\n## 🏁 Quick Start\n\n### 1. Unified MCP Server (Claude Code, Gemini, Codex)\n\nSMRITI can be used as a global, persistent memory layer across all your MCP-enabled developer clients.\n\n#### Method A: One-Line Installer (Recommended)\nRun the setup script directly in your terminal:\n```bash\nbash <(curl -s https://raw.githubusercontent.com/smriti-memcore/smriti-memcore/main/install_smriti_mcp.sh)\n```\n\n#### Method B: Via PyPI\nInstall the package and run the setup CLI:\n```bash\npip3 install smriti-memcore\nsmriti_install\n```\n\n---\n\n### 2. Python SDK\n\nFor application developers building custom agent loops.\n\n```bash\npip install smriti-memcore[faiss] # FAISS is recommended for accelerated vector search\n```\n\n```python\nfrom smriti import SMRITI, SmritiConfig\n\n# Initialize memory engine with OpenAI\nconfig = SmritiConfig(\n    storage_path=\"./my_agent_memory\",\n    llm_model=\"gpt-4o\",\n    openai_api_key=\"your-api-key-here\"\n)\nmemory = SMRITI(config=config)\n\n# Ingest observations\nmemory.encode(\"User prefers using PyTorch for neural networks.\")\nmemory.encode(\"User is allergic to shellfish.\", context=\"medical\")\n\n# Recall relevant context using multi-factor retrieval\nresults = memory.recall(\"What framework does the user prefer?\")\nfor mem in results:\n    print(f\"[{mem.strength:.2f}] {mem.content}\")\n\n# Manually trigger System 2 background consolidation\nmemory.consolidate()\nmemory.save()\n```\n\n---\n\n## 🛠️ MCP Tool Reference\n\nSMRITI exposes **19 tools** (13 native + 6 AMP aliases) for clients:\n\n### Core Tools\n\n| Tool Name | Description |\n|---|---|\n| `smriti_encode` | Ingests a new memory. Accept `private=True` to exclude from team syncs. |\n| `smriti_recall` | Retrieves memories using semantic and graph-based retrieval. |\n| `smriti_get_context` | Helper to inject the current active working memory slots into the context window. |\n| `smriti_how_well_do_i_know` | Performs a meta-memory confidence check on a given topic. |\n| `smriti_knowledge_gaps` | Identifies topics the agent has identified it needs more information on. |\n| `smriti_pin` | Marks a memory as permanent (protects it from strength decay). |\n| `smriti_forget` | Soft-deletes/archives a memory, leaving a cryptographic tombstone. |\n| `smriti_consolidate` | Triggers a background System 2 consolidation run. |\n| `smriti_stats` | Returns system-wide statistics (total memories, rooms, private counts). |\n| `smriti_create_private_room` | Spawns a private room. All memories inside this room are visibility-isolated. |\n| `smriti_open_ui` | Launches the interactive visual D3.js memory graph in your default browser. |\n| `smriti_sync_obsidian` | Exports the Semantic Palace graph structures to markdown files in an Obsidian Vault. |\n\n### AMP v1.0 Alias Tools\nThese endpoints ensure complete conformance with the standard Agent Memory Protocol specification:\n\n| AMP Tool | Native Mapping | Return Format |\n|---|---|---|\n| `amp.encode` | `smriti_encode` | AMP standard JSON response |\n| `amp.recall` | `smriti_recall` | Array of `{id, content, score, timestamp, status}` |\n| `amp.forget` | `smriti_forget` | `{status: \"forgotten\" \\| \"not_found\"}` |\n| `amp.stats` | `smriti_stats` | `{memory_count, ...}` |\n| `amp.pin` | `smriti_pin` | `{status: \"pinned\" \\| \"not_found\"}` |\n| `amp.consolidate` | `smriti_consolidate` | `{status: \"ok\", memories_processed: int}` |\n\n---\n\n## 🔌 Framework Integrations\n\n### LangChain Integration\nUse `SmritiLangChainMemory` as a drop-in replacement for default chat buffers. It limits active context using Working Memory and offloads the conversational history to the Semantic Palace graph in the background.\n\n```python\nfrom langchain.chains import ConversationChain\nfrom smriti.integrations.langchain_memory import SmritiLangChainMemory\nfrom smriti import SMRITI\n\nsmriti_engine = SMRITI(storage_path=\"./langchain_smriti_db\")\nsmriti_memory = SmritiLangChainMemory(smriti_client=smriti_engine, top_k=3)\n\nconversation = ConversationChain(\n    llm=my_llm,\n    memory=smriti_memory,\n)\nconversation.predict(input=\"I prefer backend APIs in Python.\")\n```\n\n---\n\n## 📊 Benchmarks & Performance\n\n### 1. LoCoMo (Multi-System Context Retrieval)\nTested against four architectures on the [LoCoMo](https://github.com/snap-research/locomo) long-context dialogue dataset (28 turns, 15 evaluation questions):\n\n| System | F1 Score | Latency | Tokens/Query | Consolidation |\n|---|---|---|---|---|\n| FullContext | **0.345** | 1147ms | 550 | — |\n| MemGPT-style | 0.334 | 1397ms | 478 | — |\n| NaiveRAG | 0.312 | 1387ms | 145 | — |\n| **SMRITI** | 0.279 | 1317ms | **146** | 41.2s (async) |\n| Mem0-style | 0.235 | 1088ms | 106 | — |\n\n*SMRITI retains high recall while drastically reducing query context size. Consolidation runs in the background and does not block client interactions.*\n\n### 2. LongMemEval (Long-Term Chat Sessions)\nEvaluated over 50+ chat sessions using the [LongMemEval](https://github.com/xiaowu0162/LongMemEval) harness:\n\n| System Configuration | Exact Match Accuracy | Average Query Latency |\n|---|---|---|\n| Baseline (Full Context) | **100.0%** | 11.98s |\n| **SMRITI Dual-Process** | **80.0%** | **0.98s** (12× latency reduction) |\n\n---\n\n## ⚙️ Configuration Parameters\n\nInitialize `SmritiConfig` with custom parameters to tune the cognitive weights:\n\n```python\nfrom smriti import SmritiConfig\n\nconfig = SmritiConfig(\n    working_memory_slots=7,          # Capacity limit (Miller's Law)\n    \n    # Retrieval scoring weights (sum to 1.0)\n    recency_weight=0.2,\n    relevance_weight=0.4,\n    strength_weight=0.2,\n    salience_weight=0.2,\n\n    # Forgetting & Temporal Decay\n    decay_rate=0.99,                 # Strength multiplier per day\n    strength_hard_threshold=0.05,    # Memories dropping below this are forgotten\n    \n    # Palace Graph\n    room_merge_threshold=0.85,       # Cosine similarity for auto-merging semantic rooms\n)\n```\n\n---\n\n## 📄 Citation\n\nIf you use SMRITI in your research, please cite our technical paper:\n\n```bibtex\n@article{tyagi2025smriti,\n  title={SMRITI: A Scalable, Neuro-Inspired Architecture for Long-Term Event Memory in LLM Agents},\n  author={Tyagi, Shivam},\n  year={2025},\n  doi={10.13140/RG.2.2.25477.82407}\n}\n```\n\n---\n\n## 📄 License\n\nSMRITI is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n",
  "bytes": 10946,
  "sha": "c15ee469161abe0fd1bb03fcf527ac1b195b3387b97d77fe638b56e0952c3d17",
  "repo_slug": "smriti-memcore/smriti-memcore",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_shivamtyagi18_smriti_memory_6e4d4cf2/readme"
}