In scaffold · Q3 2026

Building AI Applications with KAOS

A Practitioner's Guide from Library to Production

A working guide for Python developers shipping legal-AI features into production. The book covers what KAOS gives you as a library, how the typed document AST holds up under real corpora, how to build extraction and retrieval pipelines that survive contact with regulators and opposing counsel, and how to put your own tools and modules into the agent runtime. The aim is grounded, verifiable, cost-aware applications, not demos.

What the reader can do at the end of each chapter:

  • Chapter 1 — install KAOS, parse a 10-K to a typed ContentDocument, and read the citation anchor on every paragraph.
  • Chapter 2 — walk an EDGAR filing's typed tree, query it by section, and round-trip it through JSON without losing source location.
  • Chapter 3 — write a parser pass that extracts every defined term in a contract along with its first-use location, validated against a fixture set.
  • Chapter 4 — build a retrieval pipeline over a deal-room corpus that returns a GroundedAnswer[T] with verifiable spans, and a typed InsufficientEvidence refusal when the evidence does not support the claim.
  • Chapter 5 — run a research-pattern agent against a citation rubric, observe per-tool spend with the cost-meter hooks, and apply a confidence-floor refusal policy.
  • Chapter 6 — put a flagged-issues diligence pass behind a Vite + React + TanStack front end, with a Caddy reverse proxy and the audit trail surfaced in the UI.
  • Chapter 7 — write a KaosTool that pulls every change-of-control clause from a parsed contract, mark its safety annotations correctly, and ship it as an MCP server other teams can install.
  • Chapter 8 — deploy the result with budget caps, retention windows, and a hash-chained audit log a partner can review.

Bommarito · Katz · Bommarito · Q3 2026 · outline available

The arc through the chapters

Chapters 1 and 2 cover the library and the typed document tree. Chapter 3 writes a real extractor. Chapter 4 builds retrieval that returns either a grounded answer or an explicit insufficient-evidence refusal. Chapters 5 and 6 sit the result behind an agent and a front-end. Chapters 7 and 8 ship a tool other teams can install and deploy with the budget caps and audit log a partner will review.

Library + AST CH 01-02 Extraction CH 03 Retrieval + RAG CH 04 Agents + Apps CH 05-06 Tools + Deploy CH 07-08 parse a 10-K walk the typed tree JSON round-trip defined-term pass first-use location fixture validation grounded answer verifiable spans typed refusal state research-pattern agent cost-meter hooks TanStack front-end a publishable tool budget caps hash-chained audit OUTCOME

The full chapter table of contents and a sample chapter will appear here as the book moves out of scaffold. The conceptual reading the book builds on is at ai4lf.com.