Prompt or hook?
This is the exam's most common trap. A rule that must hold every time comes with answers that make the prompt clearer. A nice-to-have comes with answers that build code. Learn to tell the two apart, and a whole family of questions becomes easy.
D1 Agentic ArchitectureExam guide 1.4 and 1.5About 15 minutes
Start here: the cashier and the till
A shop has two ways to make its cashiers behave.
Claude works the same way. A prompt (instructions, plus a few example chats) is the note by the till: followed most of the time, cheap to change. A hook is code that runs every time Claude calls a tool. It is the till that won't open.
- Yes (a suggestion, a tone, a style): use a prompt instruction plus a few examples.
- No, an action must not run (a refund over the limit): a PreToolUse hook that blocks the call.
- No, data must not reach Claude (a card number): a PostToolUse hook that strips it from the result.
- No, one step must come before another (verify identity, then refund): a prerequisite gate in code.
Words in the question that tell you which side you're on
Prompt side
- suggest, encourage, prefer
- tone, style, wording
- “a retention idea, not a business rule”
- “most appropriate”, “simplest”: they ask for the right size, not the strongest
Code side
- must, never, every time, stop completely
- money, refunds, identity, security, compliance
- “a prompt already says so, yet…”
- “guarantee”, “deterministic”
Try it: run 1,000 chats
Pick a behaviour, then pick how you'd make Claude follow it. The simulator replays 1,000 chats where the behaviour matters, and the diagram above shows where your choice acts.
The rates are illustrative, chosen to show the shape. They are not measurements. The exam guide's point is that prompt instructions have a non-zero failure rate, while hooks are deterministic for what they can see: tool calls and tool results.
Things to try: refund + prompt, then refund + PreToolUse. Then pause + PreToolUse to see the trap in reverse. Last, card number + PreToolUse, the right family but the wrong hook.
The three traps
| Trap | What the wrong option looks like | Why it's wrong |
|---|---|---|
| Prompt where code was needed | “Move the rule to the top of the prompt”, “add examples”, “state it in capitals”, for a money, security or must-never rule | Prompts are followed most of the time. A rule that must hold every time needs code. |
| Code where a prompt was enough | A hook, classifier or new subagent for a suggestion or a tone | Overbuilt. More to build and maintain, and it can block real users when it misreads. |
| Right family, wrong hook | PostToolUse to stop an action; PreToolUse to hide data; a hook that only logs | PreToolUse acts on the call, before it runs. PostToolUse acts on the result, before Claude reads it. Logging prevents nothing. |
“But as an architect, it depends”
Take the retention feature from practice question 1: before a cancelling customer is handed to a person, the agent suggests pausing the subscription. In real life the right design does depend on the requirement. The exam removes the “it depends” by stating the requirement in the question. Your job is to find that sentence and build exactly what it asks for, not the system you would design if you owned the product.
| If the question says… | Best answer | A retention subagent? |
|---|---|---|
| It's a nice-to-have; the agent doesn't have to do it in every chat | A system-prompt instruction plus two example chats | No. Overbuilt: a handoff and a second prompt for one sentence of behaviour. |
| Only some customers may be offered a pause, under rules finance sets | A tool such as get_retention_offer(customer_id) that checks the policy in code, plus a prompt line saying when to call it and how to word the offer | No. A subagent is still a model deciding who is eligible. A policy belongs in code or data. |
| A pause must be offered before every cancellation (a compliance rule) | A PreToolUse hook that blocks escalate_to_human until the offer is recorded | No. A subagent can't guarantee it either. |
| Retention is a long negotiation with its own tools, offers and history | A retention subagent | Yes. Now the separate context and focused prompt earn their cost. |
On the exam, the most appropriate answer is the smallest mechanism that fully meets the stated requirement. An option that meets a requirement the question never gave is the “overbuilt” trap, however good the design.
Tool A must run before tool B: every way, and which one wins
Many questions come down to one shape: the agent must call A (verify the customer, preview a removal, search for a connector) before B (refund, remove, call the connector), and it sometimes skips A. There are eight ways to enforce it. Questions with the same shape can have different answers because they give different options and stress different words.
| # | Way | How it works | What it guarantees |
|---|---|---|---|
| 1 | System prompt instruction | “Always call A before B” | Nothing. Followed most of the time, not every time. |
| 2 | Tool description and few-shot examples | The same request, written into each tool's description | Nothing. It raises the rate but never makes it certain. |
| 3 | Merge A and B into one tool | A single tool does A and then B | The order, but the model can no longer check between the steps (the find_and_execute trap). |
| 4 | Hide B until A has run | A dynamic tool list: B appears only after A | The order. The answer when there are too many tools and the agent calls tools it never searched for. |
| 5 | PreToolUse hook in the host or Agent SDK | Code checks that A has run in this session before allowing B, and blocks B otherwise | The order, but only inside that host. |
| 6 | Server remembers recent calls | For example, “allow B only if a matching A ran in the last 60 seconds” | The order, but fragile: a slow user misses the window, and one A can be reused within it. |
| 7 | A returns a token that B requires | B's own input needs something only A can produce, valid once and only for that action | The order and the exact data, whoever calls the tool. |
| 8 | Fixed workflow code | Your code calls A and then B, and the model doesn't choose | Everything, but the model has no flexibility. Right when the steps never change. |
| + | Human approval gate | The host asks the user before B runs | A person's sign-off. Combine it with 5 or 7, because on its own the user may approve without ever seeing A's result. |
How to pick: read the question for these clues
| If the question… | Best answer |
|---|---|
| Says the agent sometimes skips A, and the options are prompts, examples and one hook or programmatic check | The hook (5). It's the only option enforced in code. |
| Is about the Claude Agent SDK or Claude Code, or about a policy such as “verify identity before any refund” | The hook (5). |
| Is about designing the tool itself (your MCP server, its parameters), or says B must be tied to that specific A | The token (7). |
| Says the user must explicitly confirm | A host approval gate on top of 5 or 7. |
| Has too many tools, and the agent calls tools it never searched for | Hide B until A has run (4). |
| Describes steps that are always the same and need no judgment | Fixed workflow code (8). |
Worked example: why it's the token here and not the hook
“Your remove_team_member tool has a dry_run parameter. The agent skips the preview in 15% of calls. You need every removal to be preceded by a preview the user explicitly confirms.” The options were: (A) allow dry_run=false only if a matching preview ran in the last 60 seconds; (B) two tools, where the preview returns a single-use token that execute requires; (C) mark the tool as needing confirmation and have the host ask the user; (D) better instructions and examples.
| Option | Enforced in code? | Tied to the exact preview? | Robust? | Verdict |
|---|---|---|---|---|
| B. Single-use token | Yes | Yes | Yes | Pick. The only way to get a token is to run the preview. |
| A. 60-second window | Yes | Partly | No | Works, but fragile: it depends on timing, and one preview can be reused. |
| C. Host asks for approval | Yes | No | Partly | Works, but the user approves a call without ever seeing a preview. MCP tool annotations are only hints. |
| D. Better instructions | No | No | No | Only usually works. The agent already skips the preview 15% of the time. |
Why not a PreToolUse hook? It wasn't one of the options, and it would be weaker here for three reasons. A hook sees one call at a time, so to know a preview happened it would have to rebuild option A or B inside itself. It only runs in one host, while the tool may be called from any client. And “never remove without a preview” is a business rule that belongs inside the tool. The hook is still useful alongside the token, as the place where the user approves: the token proves a preview happened, and the approval proves a person said yes.
To choose, work through three steps. First, drop anything that is only a prompt when the question says “every” or “always”. Second, drop fragile fixes such as timers, time windows and hints that the host may ignore. Third, choose among what's left using the clue table above.
Practice: three exam-style questions
Answer first, then open “Think it through”.
Rule to remember
Exam guide 1.4: “When deterministic compliance is required (e.g., identity verification before financial ops), prompt instructions have a non-zero failure rate.” Exam guide 1.5: “Hooks give deterministic guarantees vs prompt-based probabilistic compliance.”