Act 08 · The plumbing 2:30 Skills, hooks, rules — and their limits

Hooks: injecting control into the loop.

A hook is custom code the harness runs at a defined point in the agent's loop — before/after a tool call, at the start/end of a turn — letting you splice deterministic control into a probabilistic process.

Video rendering soonThe cinematic render for this episode is being generated. The article, transcript and key ideas are all here now.

Key ideas

  • The one idea — A hook is custom code the harness runs at a defined point in the agent's loop — before/after a tool call, at the start/end of a turn — letting you splice deterministic control into a probabilistic process.
  • How it is shown — A hook firing right before a shell command runs, checking it against a blocklist and cancelling a destructive one before it executes.
  • The trap to avoid — Confusing a hook with a prompt instruction — a hook is code that always runs (deterministic), not a request the model may or may not honor.
  • What it sets up — Hooks are hard, deterministic control — but what about the soft instructions in the prompt?

A prompt instruction is a request the model might ignore. A hook is code that runs every single time, at a fixed point in the loop. Requests versus guarantees.

The one idea

A hook is custom code the harness runs at a defined point in the agent's loop — before/after a tool call, at the start/end of a turn — letting you splice deterministic control into a probabilistic process.

Skills add capability. Hooks add control. Recall the agent loop — think, act, observe, repeat. A hook lets you run your own code at a fixed point in that loop, every time it passes. It's how you steer the machine while it runs. A hook is a checkpoint you define in the cycle — before a tool runs, after it returns, at the start or end of a turn. When the loop reaches that point, the harness pauses, runs your code, then continues. You're splicing your own logic into the machinery. What runs there is up to you. A hook can inspect what the model's about to do and block it, log every action, reformat a tool's output, or inject a reminder into context.

How it works — the demo

A hook firing right before a shell command runs, checking it against a blocklist and cancelling a destructive one before it executes.

Small pieces of code at exact moments — validate, block, log, transform. Here's why hooks matter. The model is probabilistic — it usually follows instructions, but not always. A hook is code: it runs every time, exactly as written. So for anything that must happen — a safety check, a hard limit — you don't ask the model and hope. You hook it, and make it certain. Take the classic case: an agent that can run shell commands. You don't want to just hope it avoids a destructive one. So you add a hook before every command that checks a blocklist and cancels anything dangerous. The model proposes; the hook disposes — guardrails wired in as code.

The trap to avoid

Confusing a hook with a prompt instruction — a hook is code that always runs (deterministic), not a request the model may or may not honor.

Why it matters — and what’s next

Hooks are hard, deterministic control — but what about the soft instructions in the prompt?

The trap: confusing a hook with a prompt instruction. Don't delete files in the system prompt is a request the model may ignore, or be tricked past. A hook that blocks deletes is code that always runs. Rules ask; hooks enforce. For anything that must hold, reach for the hook. So a hook is code the harness runs at a fixed point in the loop, every time — deterministic control in a probabilistic process: validate, block, log, transform. That's hard control. But most behavior is still shaped by soft instructions — the rules in the prompt. How far can those go? Next: rules, and their limits.

This is one short episode in AI: Zero → Frontier, a step-by-step climb through how AI actually works. Each episode builds only on the ones before it.

Full transcript 2:30 of narration

Skills add capability. Hooks add control. Recall the agent loop — think, act, observe, repeat. A hook lets you run your own code at a fixed point in that loop, every time it passes. It's how you steer the machine while it runs.

A hook is a checkpoint you define in the cycle — before a tool runs, after it returns, at the start or end of a turn. When the loop reaches that point, the harness pauses, runs your code, then continues. You're splicing your own logic into the machinery.

What runs there is up to you. A hook can inspect what the model's about to do and block it, log every action, reformat a tool's output, or inject a reminder into context. Small pieces of code at exact moments — validate, block, log, transform.

Here's why hooks matter. The model is probabilistic — it usually follows instructions, but not always. A hook is code: it runs every time, exactly as written. So for anything that must happen — a safety check, a hard limit — you don't ask the model and hope. You hook it, and make it certain.

Take the classic case: an agent that can run shell commands. You don't want to just hope it avoids a destructive one. So you add a hook before every command that checks a blocklist and cancels anything dangerous. The model proposes; the hook disposes — guardrails wired in as code.

The trap: confusing a hook with a prompt instruction. Don't delete files in the system prompt is a request the model may ignore, or be tricked past. A hook that blocks deletes is code that always runs. Rules ask; hooks enforce. For anything that must hold, reach for the hook.

So a hook is code the harness runs at a fixed point in the loop, every time — deterministic control in a probabilistic process: validate, block, log, transform. That's hard control. But most behavior is still shaped by soft instructions — the rules in the prompt. How far can those go? Next: rules, and their limits.

PlumbingHooksControl