CCA Prep

Lesson 1.5Lesson 5 of 30

Agent SDK hooks

Apply Agent SDK hooks for tool call interception and data normalization

Agent SDK hooksModeltool callInterception hook: policy check> $500 → escalate_to_humanTool runsPostToolUse hook: normaliseresult1718035200 · 2024-06-10T16:00Z · 3 →one format

Key points

  1. 1A hook on outgoing tool calls checks policy before the tool runs, and can block and redirect, e.g. a refund over $500 goes to escalate_to_human.
  2. 2A PostToolUse hook transforms tool results before the model sees them: Unix timestamps and ISO 8601 into one format, numeric status codes into words.
  3. 3Hooks are code, so the guarantee is deterministic. Prompts give probabilistic compliance.
  4. 4Rule of thumb: a business rule that must never be broken belongs in a hook; style and judgment belong in the prompt.
What the exam guide checks here

Objective wording from the exam guide (English).

  • 1.5.K1PostToolUse-style hooks transform tool results before the model sees them
  • 1.5.K2Hooks intercepting outgoing tool calls enforce compliance rules (e.g. refund threshold)
  • 1.5.K3Hooks give deterministic guarantees; prompts give probabilistic compliance
  • 1.5.S1PostToolUse hooks normalise heterogeneous formats (Unix timestamps, ISO 8601, numeric status codes)
  • 1.5.S2Interception hooks block policy-violating actions and redirect (e.g. refunds > $500 to human escalation)
  • 1.5.S3Choose hooks over prompts when business rules need guaranteed compliance

Lock it in

Answer scenario questions on this topic. Every option comes with an explanation.

Practise 1.5 · 20 questions