Programmatic Preconditions
Block refunds until identity is verified, in code.
The Refund That Should Never Fire
Picture a customer support agent with a process_refund tool. The model is smart, but it is also probabilistic. Roughly 9 times out of 10 it follows your instruction to verify the customer first. The tenth time, under an unusual prompt or a confusing conversation, it refunds an unverified stranger.
For a financial action, a 90% success rate is a liability, not a feature. This lesson is about closing that 10% gap with a programmatic precondition: a deterministic code-level gate that blocks the refund until identity is verified — every single time.
Prompts Persuade, Code Guarantees
There are two ways to enforce a rule in an agent:
- Prompt guidance — "Always verify the customer before refunding." This is ~90% reliable. The model decides whether to comply.
- Programmatic enforcement — a hook or code check that runs deterministically. This is 100% reliable. The model cannot override it.
The exam rule of thumb: when failure has financial, legal, or safety consequences, you do not trust a prompt. You reserve hard code for guarantees, and let the model make the open-ended decisions.
All lessons in this course
- PostToolUse & Outgoing-Call Hooks
- Deterministic Enforcement vs Prompts
- Programmatic Preconditions
- Structured Handoff Protocols