A book introducing Tactus: durable orchestration for tool-using AI agents. Tactus builds on DSPy for LLM programming primitives (signatures, modules, optimizers) and adds a higher-level DSL with durability, sandboxing, and human-in-the-loop.
Read online: https://anthusai.github.io/Learning-Tactus/ Latest PDF: https://anthusai.github.io/Learning-Tactus/pdf/Learning-Tactus.pdf
This book is built with Quarto. To build:
./scripts/preview-book.shThen open http://127.0.0.1:4444 (the port stays fixed unless something else is using it).
quarto render --to htmlThe HTML output will be in _output/index.html (book cover) and _output/chapters/*.html (chapters).
If you want HTML and PDF outputs to stop deleting each other during single-format renders, use:
./scripts/render-html.sh
./scripts/render-pdf.shOr run both in one go:
./scripts/render-all.shThat produces stable outputs at:
_output/html/index.html_output/pdf/Learning-Tactus.pdf
Note: _output/index.html is overwritten post-render with cover.html (see _quarto.yml project.post-render), and the book’s preface now lives in chapters/00-preface.qmd. The cover expects a square animal image at images/cover-animal.png (or cover-animal.png).
quarto render --to pdfThe PDF output will be in _output/Learning-Tactus.pdf with custom formatting and cover.
quarto render- Part I: Foundations — What Tactus is, plus transparent durability, everything-as-code, and a quick install to run the examples.
- Part II: Build a Useful Agent — A single running example, iteratively extended until it’s useful (including HITL).
- Part III: Guardrails (Safety + InfoSec) — Capability control, sandboxing, isolation boundaries, and secretless execution.
- Part IV: Reliability and Correctness at Scale — Behavior specs and evaluations.
- Part V: Putting It Together — Complete examples you can adapt.
All code examples are in the code/ directory, organized by chapter. Each example:
- Is a runnable
.tacfile - Includes embedded BDD specifications for testing
- Can be tested with
tactus test code/**/*.tac
To keep examples correct and CI-backed, code/ is copied directly from the main Tactus repo’s examples/ directory (../Tactus/examples). Prefer updating the upstream example in the Tactus repo, then re-copying it into this book.
This book tracks which upstream Tactus commit it targets in tactus-target.yml. Update it from a local Tactus checkout (sibling repo layout assumed):
bash scripts/update-tactus-target.sh ../TactusCI uses tactus-target.yml to install the matching Tactus commit when validating/testing examples, and the book prints the pinned version in the Preface.
Chapters can include code directly from files under code/ at render-time (so the book can’t drift from runnable examples).
Use a fenced code block with a file="..." attribute (optionally snippet="..." and show-path="true"):
```lua {file="code/chapter-02/10-feature-state.tac" snippet="durable-loop" show-path="true"}
```show-path="true" renders a small filename label above the code block in HTML output. For PDF output, it renders a Source: ... line above the block.
If you use snippet="...", the included file must contain matching markers:
-- snippet:start durable-loop
-- ...
-- snippet:end durable-loopIf you prefer line-based slicing instead of snippet markers, use lines="..." (1-based, inclusive):
```lua {file="code/chapter-02/10-feature-state.tac" lines="15-35"}
```You can also use open-ended ranges:
lines="15-"(from line 15 to end)lines="-35"(from start through line 35)lines="15"(just line 15)
To verify includes are valid:
python scripts/check-snippet-includes.pyThe GitHub Actions workflow automatically validates and tests all examples:
# Validate syntax
tactus validate code/**/*.tac
# Run BDD tests
tactus test code/**/*.tacThis repo includes a runnable demo procedure that compares each chapters/*.qmd file against the Tactus specification:
tactus run sync-book-with-spec.tac --param max_chapters=3It expects the Tactus repo to exist at ../Tactus and uses sandbox volume mounts configured in sync-book-with-spec.tac.yml.
Outputs:
_output/spec-sync/spec-summary.txt_output/spec-sync/report.txt
- PDF: Custom styling with magenta title blocks and LaTeX cover
- HTML: Clean, simple styling for web readability
- Target Audience: AI/ML practitioners frustrated with fragile agent scripts
- Hook: Transparent durability - write normal code, get resilience for free
Ryan Porter
Anthus AI Solutions