Building trustworthy agent query systems, from certain-answer semantics to provenance semirings.
This book teaches you to build agent query systems that cannot produce confident falsehoods.
The industry conversation about AI agents querying enterprise data is mostly about retrieval quality and SQL generation accuracy. Those are the easy half. The hard half is that a query engine assembled from a search index, a warehouse, and three SaaS APIs has no shared notion of what a correct answer even is — and an LLM sitting on top of it will smooth over every seam with fluent English.
The problems this creates are not new. They were named in the database literature between 1984 and 2007, under headings — certain answers, summarizability, the Non-Truman model, provenance semirings — that almost nobody building agent infrastructure has encountered. The problems are solved and unread. This book reads them for you, translates them into engineering decisions, and shows you how to build a query layer where the only answers the system can produce are the honest ones.
The premise is that wrong answers from agent systems are not a model-capability problem that will be solved by the next release. They are type errors — operations applied to data that cannot support them, reported without the metadata that would make the limitation visible. The fix is not better prompting. It is a type system over your query plan, carrying annotations that make unsound operations unrepresentable.
Engineers building systems where an LLM queries structured and unstructured enterprise data and narrates the result. You are comfortable with SQL and have built or maintained a data pipeline. You do not need a background in database theory — the book teaches what it uses. You do need to be willing to think about your query layer as a compiler rather than a prompt.
Each chapter is self-contained: a schema declared at the top, a failure demonstrated against it, a fix implemented in isolation. The examples are small enough to fit in one file and run against any Postgres instance. The exercises have two tiers: Implement (build the mechanism in code, 1–2 hours) and Extend (design for a novel domain, open-ended). Chapter 7 is the capstone — a single reference implementation that ties all the annotation types together.
Working SQL. Comfort reading Python or TypeScript. Familiarity with how LLM tool-calling agents work (you’ve seen a ReAct loop or built one). Chapter 1 provides the relational algebra and retrieval foundations you need; if its content feels familiar, skip to Chapter 2.