Task Statements 1.4 & 1.5 — the most heavily tested idea on the whole exam.
Course progress: Domain 1 ▸ lesson 3 of ~4
If you learn one thing for the exam, learn this: when you need a guarantee, use programmatic enforcement — not a prompt. Prompts have a non-zero failure rate. Hooks and prerequisite gates do not.
Programmatic enforcement vs prompt-based guidance
Prompt-based
Programmatic (hooks / gates)
Nature
Probabilistic — the model usually complies
Deterministic — the rule always fires
Use when
Guidance, defaults, soft preferences
A business/safety rule must be guaranteed
Example
"Always verify the customer first"
Block process_refund until get_customer returned a verified ID
The load-bearing rule
Identity verification before financial operations, refund caps, compliance ordering — anything where an error has real consequences → enforce in code. "Enhance the system prompt to say it's mandatory" and "add few-shot examples showing the right order" are distractors when the stem asks for a reliability guarantee.
Prerequisite gates
A prerequisite gate blocks a downstream tool until an upstream step has completed. Canonical exam case: the agent sometimes skips get_customer and calls lookup_order on a stated name, misidentifying accounts. The fix that works: a programmatic prerequisite that blocks lookup_order and process_refund until get_customer has returned a verified customer ID. Prompts and few-shot examples reduce the rate but can't drive it to zero; a routing classifier addresses tool availability, not tool ordering — wrong problem.
Hooks: intercepting the loop
Hooks are code that runs at defined points in the agentic loop. Two patterns the exam names:
PostToolUse — intercepts a tool's result before the model sees it. Use it to normalize heterogeneous data: e.g., one MCP tool returns Unix timestamps, another ISO 8601, another numeric status codes — normalize them all to one format so the agent reasons over consistent data.
Tool-call interception — intercepts an outgoing tool call and can block it. Use it to enforce policy: block a refund over $500 and redirect to human escalation.
Why hooks over prompts hereBoth patterns are chosen precisely because they are deterministic. "Tell the model in the prompt not to refund over $500" is the probabilistic distractor.
Multi-concern decomposition
When one customer message contains several issues (a refund and a billing dispute and an address change), decompose it into distinct items, investigate each — in parallel where possible using shared context — then synthesize one unified resolution. Don't tunnel on the first issue.
Structured handoff on escalation
When escalating to a human who has no access to the conversation transcript, hand off a structured summary, not "customer is upset." Include: customer ID, root-cause analysis, refund amount / relevant figures, and a recommended action. The human should be able to act without re-interviewing the customer.
Check yourself
In 12% of cases the agent skips customer verification and refunds the wrong account. Which change most effectively guarantees the reliability fix?
Enhance the system prompt to state verification is mandatory first
Add few-shot examples showing verification called before any order op
Add a programmatic gate blocking order ops until verify returns an ID
Add a routing classifier enabling only tools relevant per request type
Correct: option 3. A required sequence protecting money demands a deterministic guarantee. Prompt enhancement and few-shot (options 1–2) are probabilistic and retain a non-zero failure rate. The classifier (option 4) changes which tools are available, not the order they run in — it solves a different problem.
Different MCP tools return dates as Unix time, ISO 8601, and numeric codes, confusing the agent. The cleanest place to normalize before the model reasons over them is a:
PostToolUse hook that transforms each tool result into one format
System prompt instruction describing every possible date format seen
Separate cleanup subagent invoked after the whole task completes
Forced tool_choice ensuring the date tool is always called first
Correct: option 1.PostToolUse intercepts results before the model processes them — exactly where deterministic normalization belongs. A prompt (option 2) is probabilistic; a post-hoc subagent (3) runs too late; forcing tool order (4) doesn't reconcile formats.
Decision rules to carry forward
Guarantee needed → hook or prerequisite gate (deterministic). Guidance/default → prompt. Normalize tool data → PostToolUse. Block policy-violating call → interception hook. Human handoff → structured summary (ID, root cause, amount, recommended action).
Ask your teacher. Want the full list of Agent SDK hook types, or how a gate is actually wired vs an interception hook? Ask before Lesson 4.