{"slug": "datalog-for-llms", "title": "Datalog for LLMs?", "summary": "A November 22, 2026 arXiv paper by Bruno Rucy Carneiro Alves De Lima proposes giving LLM agents a Datalog REPL over a dynamic Datalog engine so derived facts persist across questions instead of being recomputed. Across chains of questions over three knowledge graphs and two models, agents reused a relation the REPL kept in 179 of 180 cases, while SQL and Python agents wrote 23 to 82% more output tokens; with Claude Haiku 5.5, a seven-question chain at 13 million facts took a median of 48 and 56 seconds versus 31 seconds with the REPL. The paper reports that with thinking enabled, the models answer as accurately in Datalog as in SQL or Python.", "body_md": "# Computer Science > Programming Languages\n\n  [Submitted on 22 Nov 2026]\n\n# Title:Cache the Knowledge, Not Just the Prompt: Dynamic Datalog as the Action Language for LLM Agents\n\n[View PDF](https://arxiv.org/pdf/2611.29709)\n\nAbstract:An LLM agent that answers questions about a knowledge graph writes a program per question, and its tools evaluate each from scratch. We give the agent a Datalog REPL, a session over a dynamic Datalog engine, in which rules are inserted and retracted like facts while derived facts stay current. Prompt caching reuses the model's processing of what a session shares, and the Datalog REPL reuses the evaluation of it. On chains of questions over three knowledge graphs, agents reuse a relation that the REPL keeps in 179 of 180 cases, with two models, and write fewer output tokens: SQL and Python agents write 23 to 82% more. With SQL tables or a Python namespace, Claude Haiku 5.5 stores almost nothing for later questions, and a chain of seven questions at 13 million facts takes it a median of 48 and 56 s, against 31 s with the REPL. Claude Opus 5.5 matches the REPL by storing tables in SQL, and when the data changes it stores views, which are evaluated again at every read. A relation that the REPL keeps is read like a table and stays current like a view. Datalog is a niche language beside SQL and Python, and with thinking enabled the models answer as accurately with it.\n    \n\n## Submission history\n\nFrom: Bruno Rucy Carneiro Alves De Lima [\n[view email](https://arxiv.org/show-email/670e86a3/2611.29709)]\n\n**[v1]** Sun, 22 Nov 2026 19:20:27 UTC (347 KB)\n\n### Additional Features\n\n### References & Citations\n\nLoading...\n\n# Bibliographic and Citation Tools\n\nBibliographic Explorer \n\n*(*[What is the Explorer?](https://info.arxiv.org/labs/showcase.html#arxiv-bibliographic-explorer))\nConnected Papers \n\n*(*[What is Connected Papers?](https://www.connectedpapers.com/about))\nLitmaps \n\n*(*[What is Litmaps?](https://www.litmaps.co/))\nscite Smart Citations \n\n*(*[What are Smart Citations?](https://www.scite.ai/))\n# Code, Data and Media Associated with this Article\n\nalphaXiv \n\n*(*[What is alphaXiv?](https://alphaxiv.org/))\nCatalyzeX Code Finder for Papers \n\n*(*[What is CatalyzeX?](https://www.catalyzex.com))\nDagsHub \n\n*(*[What is DagsHub?](https://dagshub.com/))\nGotit.pub \n\n*(*[What is GotitPub?](http://gotit.pub/faq))\nHugging Face \n\n*(*[What is Huggingface?](https://huggingface.co/huggingface))\nScienceCast \n\n*(*[What is ScienceCast?](https://sciencecast.org/welcome))\n# Demos\n\n# Recommenders and Search Tools\n\nInfluence Flower \n\n*(*[What are Influence Flowers?](https://influencemap.cmlab.dev/))\nCORE Recommender \n\n*(*[What is CORE?](https://core.ac.uk/services/recommender))\n# arXivLabs: experimental projects with community collaborators\n\narXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.\n\nBoth individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.\n\nHave an idea for a project that will add value for arXiv's community? [**Learn more about arXivLabs**](https://info.arxiv.org/labs/index.html).", "url": "https://wpnews.pro/news/datalog-for-llms", "canonical_source": "https://arxiv.org/abs/2611.29709", "published_at": "2026-11-25 10:51:46+00:00", "updated_at": "2026-11-25 11:15:49.068580+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-research", "ai-tools"], "entities": ["Bruno Rucy Carneiro Alves De Lima", "arXiv", "Datalog", "Claude Haiku 5.5", "Claude Opus 5.5", "SQL", "Python"], "also_reported_by": [], "takeaway": "Giving agents a Datalog REPL that retains derived relations let them reuse a relation in 179 of 180 question chains and cut output tokens 23-82% versus SQL and Python agents, with a seven-question chain at 13 million facts running in 31s median versus 48-56s for Claude Haiku 5.5 on SQL or Python.", "recommendation": {"advice": "Give knowledge-graph agents a persistent Datalog REPL that keeps derived relations across questions instead of re-evaluating each query from scratch; the source measured 179/180 relation reuse and 23-82% fewer output tokens than SQL or Python agents.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/datalog-for-llms", "markdown": "https://wpnews.pro/news/datalog-for-llms.md", "text": "https://wpnews.pro/news/datalog-for-llms.txt", "jsonld": "https://wpnews.pro/news/datalog-for-llms.jsonld"}}