Skip to main content

Engram memory integration for LlamaIndex — durable, explainable memory for agents.

Project description

llama-index-memory-engram

Durable, explainable memory for LlamaIndex agents — powered by Engram.

EngramMemory is a BaseMemory implementation that replaces LlamaIndex's built-in chat-history buffer with Engram's hybrid retrieval pipeline (BM25 + vector + knowledge graph + reranker). Every message your agent sees is persisted to an Engram bucket; reads come back in chronological order, and semantic recall is one call away.

Install

pip install llama-index-memory-engram

Usage

import os
from llama_index.llms.openai import OpenAI
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.memory.engram import EngramMemory

os.environ["ENGRAM_API_KEY"] = "eng_live_..."   # or pass api_key=... explicitly

memory = EngramMemory.from_defaults(
    bucket="user-42",         # one bucket per user / session / agent
    read_limit=50,            # how many recent messages get() returns
)

agent = FunctionAgent(
    llm=OpenAI("gpt-4o"),
    tools=[...],
)

response = await agent.run(
    "What did we decide about the Q3 launch?",
    memory=memory,
)

Get an API key at https://lumetra.io. Keys look like eng_live_....

Direct semantic recall

get() returns the most recent read_limit messages, which is what agents expect from chat history. When you want hybrid retrieval over the entire bucket, call query() directly:

result = memory.query("regulatory risks we discussed last quarter")
print(result["answer"])
print(result["memories_found"])

Bucket scoping

Pick a bucket name per logical conversation scope:

EngramMemory(bucket=f"user-{user_id}")           # per user
EngramMemory(bucket=f"session-{session_id}")     # per session
EngramMemory(bucket=f"agent-{agent_id}")         # per agent

Buckets are created on first write — no admin call needed.

Self-hosted Engram

EngramMemory(
    bucket="ops",
    base_url="https://engram.internal.example.com",
    api_key="...",
)

API reference

Method Behavior
put(message) Append one ChatMessage to the bucket.
put_messages(messages) Append many.
get(input=None) Return the most recent read_limit messages, oldest-first.
get_all() Same as get().
set(messages) Clear the bucket, then write messages.
reset() Clear the bucket.
query(question) Hybrid retrieval over the entire bucket. Returns the raw Engram response.
list_buckets(limit, offset) List buckets visible to this API key.
delete_memory(memory_id) Delete a single memory by id.

All methods have async equivalents (aput, aget, ...) inherited from BaseMemory; they currently run the sync implementation in a thread.

Configuration

Constructor arg Env var Default
api_key ENGRAM_API_KEY required
bucket "default"
base_url "https://api.lumetra.io"
read_limit 50
timeout 120.0

License

MIT — see LICENSE.

For data-handling details see PRIVACY.md and https://lumetra.io/privacy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_memory_engram-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_memory_engram-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_memory_engram-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_memory_engram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae849a50346212088c9ece4ab49e49581e80b8e820a43a4dfbe65971648c2100
MD5 8d030ba7dd3810b056519e1bc9573f67
BLAKE2b-256 efa56c3e9189bf1fe9d61612183d9d97dd8b3e20529ed8b76ca6b8325e3c3443

See more details on using hashes here.

File details

Details for the file llama_index_memory_engram-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_memory_engram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a331d95d760d6c093574e914f99e2c82cb84faccde8995c1e687405fedc87d4b
MD5 dc183b9757a0e4b7512a394fb517e6c8
BLAKE2b-256 7c512d31128ac4a077d37a02a1d34e96db04c7597d29faac226a44ab9b0e2f15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page