Skip to content

🧠 Using Memory

Antilogix comes with a built-in Memory System powered by Mem0. This allows your agents to remember user preferences, facts, and past interactions across different sessions.

Enabling Memory

  1. Open sentinel.yaml and ensure memory is configured:

    yaml memory: provider: "mem0" user_id: "default_user" # Default ID if none is provided at runtime

  2. Add your Mem0 API Key to .env:

    ini MEM0_API_KEY=m0-your-key-here

Automatic Memory

The BaseAgent handles memory automatically.

  • Retrieval: When you call agent.think(query, user_id="123"), Antilogix searches the memory store for facts relevant to query and user_id. These are passed to _set_system_prompt.
  • Storage: After the agent responds, the interaction (User Query + AI Response) is analyzed, and new facts are automatically saved to Mem0.

Manual Memory Operations

For advanced use cases, you can interact with the memory store directly.

from antilogix.container import ServiceContainer

async def manage_memory():
    # 1. Get the memory instance
    container = ServiceContainer.get_instance()
    memory = container.get_memory()

    # 2. Manually add a memory
    await memory.add("User is allergic to peanuts", user_id="user_55")

    # 3. Search memory
    memories = await memory.search("food allergies", user_id="user_55")
    print(memories) 
    # Output: ["User is allergic to peanuts"]

Best Practices

  • Always pass user_id: When initializing agents or calling think(), passing a specific user_id ensures that memory is personalized (e.g., specific to one customer).

  • Context Injection: Ensure your _set_system_prompt method actually uses the context_notes argument, or the retrieved memories will be ignored.