To address the issue of LLM agents losing track of established facts during long-running vulnerability research, the author developed Lemmalog, a system that treats LLM memory as a formal program analysis task rather than simple semantic retrieval. Unlike traditional vector databases that rely on cosine similarity, Lemmalog utilizes a Datalog engine to maintain a deterministic, structured state of "what is currently true." In this architecture, the LLM acts as a probabilistic front-end that extracts facts from messy inputs (like debugger output or source code), while the Datalog engine handles the logic through rules and derivations. This allows for incremental evaluation, where updating or retracting a single fact automatically invalidates all dependent conclusions via provenance tracking. In benchmarks, Lemmalog demonstrated significant advantages in specific categories: it outperformed existing systems in "Knowledge Update" tasks (scoring 0.579 vs. PropMem's 0.528) and showed superior performance in adversarial questions where it correctly rejected unsupported premises. Furthermore, Lemmalog significantly reduced token overhead; in LongMemEval, it required approximately 2,700 tokens per question compared to the 104,000 tokens required by full-context prompting, representing a 38x reduction in query-time context.

Read original