Deterministic Enforcement vs Prompts
Hooks are 100% certain; prompts are ~90% probable.
Two Ways to Enforce a Rule
When you need an agent to always follow a rule, you have two fundamentally different tools.
- Prompts ask the model to behave a certain way. The model usually complies — but it's still a probabilistic system making a judgment call.
- Hooks are deterministic code that runs around tool calls. They don't ask — they enforce.
This lesson teaches the single most important number in workflow enforcement: a well-written prompt gives you roughly ~90% compliance; a hook gives you 100%.
Prompts Are Probabilistic
A system prompt is guidance. Even an excellent one — explicit criteria, few-shot examples — steers the model toward the right behavior but never guarantees it.
Across thousands of requests, that residual ~10% surfaces: an edge case, an unusual phrasing, a long context where the rule sits in the lost-in-the-middle zone. The model generalizes from your instructions, which is exactly why it can also generalize wrong.
For most behaviors that's fine. For rules where a single violation is unacceptable, ~90% is a liability.
system = (
"You are a refund agent. "
"NEVER issue a refund above $500 without manager approval."
)
# This is guidance. The model will *usually* obey —
# but 'usually' is not 'always'. There is no code path
# that physically blocks a $501 refund.All lessons in this course
- PostToolUse & Outgoing-Call Hooks
- Deterministic Enforcement vs Prompts
- Programmatic Preconditions
- Structured Handoff Protocols