Agent lesson 05 · Control lifecycle events
Shared teaching scenario · fictional product data
Research three laptops under €900, verify current evidence, and write laptop-comparison.md. Do not purchase anything or contact a vendor.
01 · Smallest useful mechanism
Pre-action hooks can validate, redact, deny, or require approval before execution. Post-action hooks can verify outcomes and record audit evidence. Session and completion hooks can enforce cleanup or acceptance checks. Hooks complement—not replace—permissions, sandboxing, schemas, and application authorization.
Attach a check at the earliest event that has enough evidence to decide and still has enough control to prevent or transform the effect.
02 · Experiment
Deterministic browser simulation
The control lifecycle events experiment uses inspectable, repeatable teaching data. It does not claim to be a live agent trajectory.
03 · Production-minded practice
Use your own stack or a contained mock environment. Do not point failure drills at real accounts, people, or irreversible services.
Map budget, permission, provenance, output, completion, and audit checks to named lifecycle events with allow, deny, transform, recover, or record behavior.
Deliver the same completion event twice, then make the purchase guard unavailable while a forbidden cart call is pending.
Replay does not duplicate effects, the high-risk call fails closed, and the trace distinguishes hook failure from a model or tool failure.
Your learning artifact
Stored only in this browser. No account required; course reset does not delete it.
04 · Check your understanding
Next: Hooks provide attachment points. The next lesson builds the full tool acceptance boundary around them.
Lifecycle timeline
Choose a rule
Hook objective
Block purchase_product before it can reserve or buy a laptop.
The event has the right evidence and timing.
The tool call is rejected before a side effect occurs.
Select the right event, then run the hook.
Research basis: Codex hooks and Claude Code hooks.