Skip to main content
Back to integrations
Backend ServicesGraph memory

LLMSlim + Neo4j

Temporal agent memory where newer facts supersede old ones, with an audit trail.

Neo4jContextStore keeps tenant-scoped memories in Neo4j. When a fact changes, supersede() links the new memory to the one it replaces, so recall() returns only what is valid now while the history stays auditable. Recalled memories are untrusted context items for the planner.

1. Package installation

Install LLMSlim and the official Neo4j SDK using your package manager.

terminalbash
pip install 'llmslim[neo4j]'

2. Architecture & execution flow

1

Open a tenant-scoped store from NEO4J_URI, NEO4J_USERNAME and NEO4J_PASSWORD.

2

Remember facts explicitly, one subject at a time.

3

When a fact changes, supersede the old memory with a reason.

4

Recall the memories valid now and plan them with the rest of the context.

3. Production code pattern

neo4j_memory.pypython
from llmslim.integrations.neo4j import Neo4jContextStore

store = Neo4jContextStore.from_env(tenant_id="tenant-42")
old = await store.remember("customer.card_address", "Ship cards to Indiranagar, Bengaluru.")
await store.supersede(old.memory_id, "Ship cards to Koregaon Park, Pune.", reason="customer moved")
items = await store.recall(subject="customer.card_address")
# Only the current address comes back; pass items to plan_context(memories=items).

4. Deployment best practices

Keep Neo4j credentials server-side, give each customer its own tenant_id, and store only facts users have agreed to keep. Use the LLMSLIM_NEO4J_* limits to cap reads and writes.

5. Key optimization tips

  • Supersede facts instead of deleting them, so answers can be audited later.
  • Recall by subject when you know it; it is cheaper and more precise than a text query.
  • Treat recalled memories as untrusted context, never as instructions.

Frequently asked questions

Troubleshooting