# Lemmalog — agent memory as a Datalog database, not a pile of text

> Lemmalog swaps an agent's vector-store memory for a Datalog database that tracks why every fact is still believed.

- Org: Jordy Zomer
- Date: 2026-08-28
- Category: tool, repo
- Source: https://pwning.systems/posts/llm-memory-program-analysis/
- Canonical page: https://ai-tldr.dev/releases/jordyzomer-lemmalog/

## In short

Lemmalog is an open-source Datalog engine that acts as memory for LLM agents. Every fact carries its provenance, so changing one fact automatically invalidates the conclusions built on it, using 6-38x fewer context tokens than full transcripts.

## What it is

Lemmalog stores an agent's memory as a deductive database instead of retrieved text snippets. Jordy Zomer built it after watching LLM agents on long vulnerability-research sessions lose track of which facts were still true and keep reasoning from ideas that had already been ruled out. The engine is written in Rust, released under MIT, and ships an MCP server so Claude Code or Kimi CLI can use it as shared memory.

## How it works

Facts and rules go into a stratified Datalog program, and every fact carries provenance. Incremental evaluation means a changed fact only re-derives the conclusions that depended on it and drops the ones that no longer hold. Agents can request a proof tree showing why any fact exists, and hybrid retrieval mixes the rule engine with text search. Entity resolution canonicalizes names so the same thing is not stored twice.

## Why it matters

The measured win is in updates and in resisting stale claims, not raw recall. On the LongMemEval oracle split Lemmalog scores 0.463 F1 using about 2,300 tokens per question, and on LoCoMo it scores 0.533 F1, third of ten systems while using 6x fewer tokens. The write-up reports 0.707 on adversarial questions against 0.509 for full-context prompting, which is the case where an agent must notice a fact was retracted.

## Who it's for

agent builders and security researchers

## Try it

cargo run --bin lemmalog

## Links

- [Write-up](https://pwning.systems/posts/llm-memory-program-analysis/)
- [Lemmalog Repo](https://github.com/JordyZomer/lemmalog)
- [Design Doc](https://github.com/JordyZomer/lemmalog/blob/main/datalog-context-engine-design.md)
