Overview
Integrating MemMachine with LlamaIndex provides a persistent memory layer for chat engines. This allows agents to:- Recall User Profiles: Surface user preferences and facts directly into the prompt context.
- Maintain Context Across Sessions: Stored episodic and semantic memories persist beyond a single execution.
- Intelligent Injection: MemMachine automatically injects relevant context as a system message during inference.
Configuration
You can configure the LlamaIndex memory component using environment variables or direct constructor parameters.1
Install Dependencies
Install the core LlamaIndex framework and the updated MemMachine client:
2
Initialize MemMachine Memory
Import the
MemMachineMemory class and configure it with your project identifiers.3
Build the Chat Engine
Equip your LlamaIndex
SimpleChatEngine with the persistent memory instance.Pro Tip: Tune the
search_msg_limit parameter to balance the depth of recall against context window usage and latency.Requirements
- MemMachine Server: Must be running (default:
http://localhost:8080). - Python: 3.12 or higher.
- LLM: An OpenAI-compatible LLM provider.

