Chapter
16
Specifying agentic systems
Part VI · Specs in an AI-built world
Lessons
About
"No payment tool runs twice for one user intent." Does your retry loop agree?
An agent is a loop around a component that promises nothing: a language model. This chapter specifies the loop, not the model. The model becomes an oracle, a nondeterministic choice among every reply it could give, and TLC explores all of them. Around it you specify what you control: the budget that stops the loop, the approval gate in front of risky tools, side effects that must happen at most once under retries and crashes, labels that keep untrusted text from steering commands, and agents sharing a board without overwriting each other. Every check is about a small model of the harness, under stated assumptions: not the harness code, and not the model's judgement.
Before you start
- Chapters 10 (fairness), 11 (refinement) and 13 (leases without clocks); chapter 15 for the habit of distrusting a fluent result.
- A working
./tla doctor(seeSTART.md). - Time: the chapter page shows the estimate, generated from the lessons.
What else is here
specs/: the lessons' models, with one small module per failure.review/(16-review): an agent teammate's output-repair loop to review.ai/1-dedupe-in-memory/(16-ai1): an AI's fix for a double charge, with its own evidence. Decide whether the conclusion follows.ai/2-correct-approval/(16-ai2): an AI-written refund approval flow. Decide, with evidence, whether it holds.gate/(16-gate): an email agent with an approval gate and at-most-once sending under crash;gate/twin/(16-gate-twin) files tickets. The skeletons supply the interface; you write the cfg.
After this chapter: capstones/agent-orchestrator/ continues it. A planner hands tasks to worker agents through a costly tool, under approvals, a budget, lost requests and crashes, and you hand your contract to a coding agent and review what comes back. The other capstones are in capstones/.
Run it
From the repository root:
./tla check 16-01
./tla check 16-review
./tla check --gate 16Run delegated or AI-written code inside the dev container, and read every diff before you run it.
Skills
hostile-env (modelling a hostile environment), intent (stating intent as properties), acceptance (acceptance criteria an implementer cannot game), evidence (knowing what a check covers).
Elsewhere
- Web version: https://indicogni.com/learn/tla-plus/16-specifying-agentic-systems/
- Recaps:
CONCEPTS.md. Hints and explanation checks:HINTS.md. Predictions without answers:PREDICT.md. - Solutions:
solutions/chapters/16-specifying-agentic-systems/. - 16-02 follows the loop of the course Build an AI Agent (
/build-your-own/build-your-agent/on the same site), with the budget check from that course's lesson on stopping.
Beyond the lessons
- 16-review Review a teammate’s spec ·
chapters/16-specifying-agentic-systems/review/·./tla check 16-review - 16-ai1 AI item ·
chapters/16-specifying-agentic-systems/ai/1-dedupe-in-memory/·./tla check 16-ai1 - 16-ai2 AI item ·
chapters/16-specifying-agentic-systems/ai/2-correct-approval/·./tla check 16-ai2 - 16-gate Gate ·
./tla check --gate 16Hints
Hint 1
Write
TypeOK,Initand the cfg first, with every action still a placeholder. Then add actions one at a time, running after each, starting withApproveandSend.Hint 2
The message id is in the log, so it survives a crash. Reuse it on every send once it exists.
Confirmasks the service about the id the agent holds;Crashloses only what is in memory;Abandonneeds the approval still missing.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Safetyis about two variables:deliveredandapproved.Livenessis aboutagentreaching one of its two final values. ForSpec, list the actions the agent's own process takes, and put weak fairness on each of those; ask which action you must leave out, and whyAbandonmakes that safe. - 16-gate-twin Gate twin, another domain ·
./tla check --gate 16 --twinHints
Hint 1
Write
TypeOK,Initand the cfg first, with every action still a placeholder. Then add actions one at a time, running after each, starting withSignOffandFile.Hint 2
The external id is in the log, so it survives a restart. Reuse it on every attempt once it exists.
Lookupasks the tracker about the id the bot holds;Restartloses only what is in memory;StandDownneeds the sign-off still missing.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Safetyis about two variables:ticketsandsignedOff.Livenessis aboutbotreaching one of its two final values. ForSpec, list the actions the bot's own process takes, and put weak fairness on each of those; ask which action you must leave out, and whyStandDownmakes that safe.