Skip to content
Daily brief
When Program Analysis Meets Agent Memory: Lemmalog Datalog Bet Pays OffBluefin and Visa Team Up to Deliver Unified Secure In-Person PaymentsWhen Program Analysis Meets Agent Memory: Lemmalog Datalog Bet Pays OffBluefin and Visa Team Up to Deliver Unified Secure In-Person Payments
Menu
Cybersecurity

When Program Analysis Meets Agent Memory: Lemmalog Datalog Bet Pays Off

A security researcher accidentally built one of the most competitive LLM memory systems by applying program analysis principles. Lemmalog, a Rust-based Datalog engine, outperforms vector-only approaches by 2.4x on benchmarks while using 45x fewer tokens.

Aug 30, 20265 min read

Editorial artwork pending

The problem with LLM agent memory is not storage — it is reasoning about what is stored.

Every major agent framework in 2026 ships some form of persistent memory: vector databases for semantic retrieval, key-value stores for structured facts, graph databases for relational knowledge. And yet, when a vulnerability researcher named Jordy Zomer set out to build an investigation tool that could track hypotheses, retract invalidated assumptions, and maintain derivation chains across multi-day analysis sessions, none of these architectures did what he needed. The tool he built instead — Lemmalog, a Rust-based Datalog engine designed as working memory for AI agents — now ranks among the top three systems on the LoCoMo benchmark and achieves 2.4x the F1 score of full-context baselines on LongMemEval, while consuming one-forty-fifth the tokens.

The irony is that Zomer was not building a memory system at all.

In a detailed technical writeup published August 28, the security researcher describes how investigation work exposed a structural gap in existing approaches. When an LLM agent disproves a hypothesis during a vulnerability investigation — say, confirming that a suspected buffer overflow is actually bounds-checked — the model continues reasoning from invalidated observations unless something external manages that retraction. Vector retrieval surfaces semantically similar content, not logically consistent content. The distinction matters when derived conclusions depend on base facts that have been withdrawn.

Lemmalog addresses this by separating responsibilities. The LLM handles what it does well: processing natural language, interpreting code, and extracting structured facts from unstructured input. Lemmalog handles what databases do well: maintaining state through facts, rules, and derived conclusions with full provenance tracking. Every stored fact carries validity intervals, confidence annotations using product t-norms, and derivation chains that answer the question “why is this true?” with an actual proof tree rather than a similarity score.

In practice, the architecture operates as a deductive database where base facts are asserted at ingestion boundaries, logical rules derive new conclusions through stratified evaluation, and retractions propagate incrementally. When a fact is removed, only conclusions that depend exclusively on that fact are invalidated — conclusions supported by alternative derivation paths survive. This is negation-as-absence with cycle rejection, not the approximate truth-maintenance that characterizes most agent memory systems.

The performance numbers tell a specific story. On LongMemEval’s 102-question benchmark, Lemmalog achieves an F1 of 0.463 with binary accuracy of 0.575, using approximately 2,300 tokens per query compared to 104,000 for full-context approaches. On LoCoMo’s larger 1,986-question suite, it places third of ten systems with an F1 of 0.533, ahead of Hindsight, Graphiti, Memory-R1, and SimpleMem while consuming one-quarter to one-sixth their token budgets. The improvement from earlier iterations — 0.226 to 0.463 F1 — came not from scaling the model but from solving concrete computer science problems: entity identity resolution, date normalization, semantic alias matching, and aggregation surfacing.

What makes Lemmalog architecturally distinct is its MCP server integration. The system exposes twelve tools through the Model Context Protocol, including lemmalog_observe for asserting triples, lemmalog_query_deep for demand-driven evaluation, lemmalog_why for proof trees, and lemmalog_what_if for hypothesis testing with guaranteed state restoration. Any MCP-compatible agent harness — Claude Code, Cursor, or custom implementations — can use Lemmalog as a shared reasoning substrate without custom integration work.

The Hacker News discussion that followed (283 upvotes, 76 comments) crystallized a broader pattern. Multiple commenters identified the approach as a resurgence of neurosymbolic AI — combining classical symbolic reasoning with neural approaches — arriving through practical necessity rather than academic agenda. Comparisons to CodeQL, answer set programming, and knowledge graphs like Cyc surfaced repeatedly. One highly-rated comment introduced the concept of “Weathering,” suggesting that repeated inferences should gradually harden into reusable system structures, reducing cognitive overhead for recurring tasks.

The limitations are specific and instructive. Lemmalog underperforms on inference tasks requiring conditional reasoning, scoring 0.164 F1 compared to PropMem’s 0.289 on that category. Soft constraints and nuanced preferences — the kind of information better captured in prose than in triples — remain a weakness. The system has also been primarily benchmarked against conversational memory tasks, not the vulnerability research scenarios that motivated its creation.

Together, these elements point to a structural shift in how we think about agent memory. The dominant 2024-2025 paradigm treated memory as a retrieval problem: embed everything, search by similarity, hope the relevant context surfaces. Lemmalog treats memory as a reasoning problem: maintain logical consistency, track provenance, propagate retractions, and assemble context strategically within token budgets. The 45x token reduction is not a compression trick — it is what happens when retrieval targets relevant facts rather than approximate neighborhoods.

What this means for practitioners building agent systems: the memory layer is no longer a solved problem you outsource to a vector database. It is an architectural decision with measurable impact on accuracy, cost, and the kinds of tasks your agents can sustain across sessions. Lemmalog is open source, benchmarked, and MCP-ready. The question is whether the rest of the ecosystem is ready to treat agent memory as infrastructure rather than afterthought.

Share

Related Coverage