Memori

repository·main·Indexed 12 days ago

https://github.com/memorilabs/memori

A persistent memory layer for AI agents that captures structured information from conversations, tool calls, and agent executions. Memori is LLM, datastore, and framework agnostic, allowing agents to recall context across sessions without significantly increasing prompt size. It features a Rust-based engine-orchestrator core with Python and Node.js SDKs, and supports integrations with Agno, CockroachDB, MongoDB, and DigitalOcean Gradient.

Tokens
142.3K
Snippets
418
Records
625
Agent score
94%

What's inside Memori

  1. Overview of Memori MCP Skills

    main

    Memori is an agent-native memory infrastructure that provides an LLM-agnostic layer for structuring memory from natural language and agent execution traces. When integrated via MCP (Model Context Protocol), it allows agents to maintain continuity across sessions, preserve decisions/constraints, and understand past actions to improve future accuracy.

    Core Principles:

    • Source of Truth: Use Memori tools for targeted recall, summaries, and durable memory augmentation.
    • Context Hierarchy: Current user instructions, verified local context, and tool results always outrank recalled memory.
    • Identity: Do not invent projectId, sessionId, or other identifiers; these are supplied via MCP request headers for authentication and attribution.
  2. Introduction to Memori BYODB

    main

    Memori is an open-source, structured memory layer for LLM applications, agents, and copilots. It captures interactions, extracts structured knowledge, and intelligently manages memory through ranking and decay to ensure agents recall relevant information across sessions.

    Key Features

    • Database Freedom: Supports a wide range of databases including CockroachDB, MariaDB, MongoDB, MySQL, OceanBase, Oracle, PostgreSQL, SQLite, and TiDB, as well as managed providers like AWS RDS/Aurora, Neon, and Supabase.
    • Full Data Ownership: Data is stored in your own infrastructure and database, ensuring compliance and regulatory control.
    • Intelligent Recall: Automatically surfaces relevant memories by ranking them based on importance and applying intelligent decay to older or less relevant facts.
    • Asynchronous Operation: Runs in the background to minimize impact on the synchronous LLM response path.

    Core Concepts

    ConceptDescriptionExample
    EntityA person, place, or thing (e.g., a user)entity_id="user_123"
    ProcessYour agent, LLM interaction, or programprocess_id="support_agent"
    SessionGroups LLM interactions togetherAuto-generated UUID or manually managed
    AugmentationBackground AI enhancement of memoriesAuto-runs after wrapped LLM calls
    RecallRetrieve relevant memories from previous interactionsAuto-injects recalled memories
  3. Manage API keys and usage in Memori Cloud

    main

    The Memori Cloud dashboard at app.memorilabs.ai provides tools for managing your integration:

    • API Keys: Create and manage keys required for authentication. The free plan includes 5,000 memories created and 15,000 recalled per month.
    • Playground: A real-time testing environment where you can chat with an AI and watch memories being extracted.
    • Memory Usage: Monitor your consumption against your plan limits.
  4. What the Memori + Agno example demonstrates

    main

    The examples/agno implementation showcases several key capabilities of the Memori integration:

    • Agno integration: Seamlessly adding Memori's capabilities to the Agno agent framework.
    • Persistent memory: Using SQLite as a backend to ensure conversations are stored and recalled automatically.
    • Context awareness: Enabling agents to remember specific details (e.g., user preferences) from earlier in a conversation.
    • Real-world application: A customer support use case demonstrating how persistent memory adds value to agentic workflows.
  5. Key Features of the Memori + Neon Integration

    main

    When using Memori with a Neon PostgreSQL backend, the following capabilities are enabled:

    • Serverless PostgreSQL: Connect to Neon's serverless Postgres with zero database management.
    • Automatic persistence: All conversation messages are automatically stored in your Neon database.
    • Context preservation: Memori injects relevant conversation history into each LLM call to maintain continuity.
    • Interactive chat: Supports interactive message input while maintaining context across the conversation.
  6. What Memori + PostgreSQL integration provides

    main

    When using the PostgreSQL integration with Memori, the following features are enabled:

    • PostgreSQL integration: Connect to any PostgreSQL database, including local instances, AWS RDS, or other managed services.
    • Automatic persistence: All conversation messages are automatically stored in your configured database.
    • Context preservation: Memori automatically injects relevant conversation history into each LLM call to maintain continuity.
    • Interactive chat: Supports interactive message input while maintaining context across the entire conversation session.
  7. Understand the Playground layout and components

    main

    The Playground interface is divided into three main areas to facilitate rapid validation of memory behavior:

    • Left Navigation: Access Memories, API keys, Playground, Documentation, and Settings.
    • Center Panel: Contains the Playground conversation interface and the message composer.
    • Right Column: Provides visibility into the extracted data via:
      • Memory usage: Monitoring resource consumption.
      • Extracted memories: A list of normalized memory statements (includes a Clean action).
      • Memory graph: A visual representation of entities and their relationships (includes an expand control).
  8. Available Memori Tools and Capabilities

    main

    Memori provides several tools for managing agent-native memory, including structured retrieval of conversation and execution traces.

    Core Tools:

    • memori_recall: Retrieve precise memories using queries, projects, sessions, or time ranges.
    • memori_recall_summary: Retrieve state summaries (e.g., daily briefs or session starts).
    • memori_compaction: Retrieve a structured post-compaction brief to resume work after context compaction.
    • memori_feedback: Report irrelevant, missing, or stale memory to improve quality.
    • memori_signup: Create a Memori account or request an API key.
    • memori_quota: Check usage, storage, or memory capacity.
  9. Key features of Memori with MongoDB

    main

    The Memori + MongoDB integration demonstrates several core capabilities for building persistent AI applications:

    • NoSQL flexibility: Leverages MongoDB's document model to store conversation data.
    • Automatic persistence: Conversation messages are automatically stored in MongoDB collections without manual save logic.
    • Context preservation: Memori automatically injects relevant conversation history into each LLM call to maintain continuity.
    • Interactive chat: Supports interactive sessions where Memori maintains context across multiple turns.
    • Cloud-ready: Designed to work seamlessly with cloud providers like MongoDB Atlas.
  10. Integration Overview for Memori Cloud

    main
    Memori is LLM-agnostic. By registering a supported client (SDK or framework instance), Memori automatically handles memory capture, augmentation, and recall. You only need your MEMORI_API_KEY and your LLM provider's credentials; no manual database setup is required. All supported providers support sync, async, streamed, and unstreamed modes.
  11. Overview of Hermes Agent integration with Memori

    main

    Memori provides the Hermes Agent with a structured, long-term memory provider designed for production agent workflows. Unlike standard conversation history, Memori captures memory from the entire agent lifecycle, including:

    • Conversation: What was said between the user and the agent.
    • Agent Trace: What the agent actually did (tool calls, workflow steps, execution paths, decisions).
    • Execution Context: Outcomes, failures, constraints, and recurring patterns.

    This integration allows Hermes to remember prior execution paths and known failure modes, preventing the agent from repeating mistakes or reprocessing long histories unnecessarily. Memori is additive and works alongside Hermes' built-in MEMORY.md and USER.md files without modifying them.

  12. How Memori captures and recalls memories

    main

    Memori works through a cycle of automatic capture and semantic retrieval:

    1. Capture: When you use a registered LLM client, Memori automatically captures the conversation and processes it via Advanced Augmentation to store facts.
    2. Recall: When a new conversation starts (even with a fresh client instance), Memori performs a semantic search to inject relevant previously stored facts into the LLM context.

    This allows the agent to maintain long-term memory across different sessions and client instances without needing to pass the entire message history manually.

    import OpenAI from 'openai';
    import { Memori } from '@memorilabs/memori';
    
    // --- Session 1: Capture --- 
    const client = new OpenAI();
    const mem = new Memori().llm.register(client);
    mem.attribution('user_123', 'test-ai-agent');
    
    await client.chat.completions.create({
      model: 'gpt-4o-mini',
      messages: [{ role: 'user', content: 'My favorite color is blue.' }],
    });
    
    // --- Session 2: Recall (New instance, no history) --- 
    const client2 = new OpenAI();
    const mem2 = new Memori().llm.register(client2);
    mem2.attribution('user_123', 'test-ai-agent');
    
    const response2 = await client2.chat.completions.create({
      model: 'gpt-4o-mini',
      messages: [{ role: 'user', content: "What's my favorite color?" }],
    });
    // Memori injects the fact, so the LLM can answer correctly.
    console.log(response2.choices[0].message.content);