Reliability is not only about catching errors after the fact; it is about not committing to a wrong interpretation in the first place. When intent is ambiguous, a well-built agent asks rather than assumes. This chapter is the exam angle on that discipline — the mechanism and its limits — and points to the handbook for the hands-on use-side workflow. The principle is durable; the tool that carries it is the illustration, so this is an architectural pattern.

Escalate, don’t guess

The foundational move is to surface a decision the model cannot make on its own. “While working on a task, Claude sometimes needs to check in with users. It might need permission before deleting files, or need to ask which database to use for a new project. Your application needs to surface these requests to users so Claude can continue with their input.” [Official] Handle approvals and user input · AnthropicT1-official original An architect’s job is to make those check-ins possible and routine — to design the agent so that hitting an ambiguity raises a question instead of silently resolving it.

AskUserQuestion: structured clarification

The mechanism is a built-in tool with a deliberately bounded shape. Each AskUserQuestion call carries 1–4 questions, each question a header (≤12 characters) and 2–4 options with a label and a description; the response maps each question to the chosen label, and free-text is handled by offering an “Other” choice and passing the typed text rather than the literal "Other". [Official] Handle approvals and user input · AnthropicT1-official original The structure is the point: bounded multiple-choice makes the human’s answer fast to give and unambiguous to route back into the agent’s flow.

The application side: the canUseTool callback

AskUserQuestion is the tool Claude calls; canUseTool is the callback your application implements to receive these interruptions and answer them. It fires on two triggers: when Claude wants to use a tool (a permission check) and when Claude calls AskUserQuestion (a clarification). [Official] Handle approvals and user input · AnthropicT1-official original So one callback is the single surface through which your app both gates tools and answers questions; it returns PermissionResultAllow / PermissionResultDeny (Python) or { behavior: "allow" | "deny" } (TS). [Official] Handle approvals and user input · AnthropicT1-official original

And its response is far richer than yes/no — the docs document six patterns:

Two interactions are worth memorizing. The callback is skipped in dontAsk mode — anything not pre-approved is denied without ever calling it (it is the last step of the permission chain, and dontAsk short-circuits before reaching it). [Official] Handle approvals and user input · AnthropicT1-official original And for a human who is not watching the terminal, the PermissionRequest hook can fire an external notification (Slack, email, push) when Claude is waiting on approval. [Official] Handle approvals and user input · AnthropicT1-official original

The interview pattern: escalate before you start

Escalation is strongest when it is proactive — ask the questions before any work depends on the answers. That is the interview pattern from D3.5: Claude interviews you with AskUserQuestion, writes a spec, and a fresh session implements from it. [Official] Best practices for Claude Code · AnthropicT1-official original The natural home for this is plan mode, since “clarifying questions are especially common in plan mode, where Claude explores the codebase and asks questions before proposing a plan.” [Official] Handle approvals and user input · AnthropicT1-official original Front-loading the questions resolves ambiguity while it is still cheap — before a single edit is built on a guessed interpretation.

The check-in as a control point

A clarifying question is also a deliberate pause, and the SDK treats it as one: the canUseTool callback “can stay pending indefinitely” while a human decides, and for long delays the agent can return a "defer" decision that ends the query and resumes later from the persisted session. [Official] Handle approvals and user input · AnthropicT1-official original That makes escalation the upstream half of human-in-the-loop — the agent yields control at the moment of uncertainty, and the human resolves what the model could not (the downstream half, routing low-confidence output to review, is D5.5). The hands-on, use-side treatment of when and how to prompt for clarification is the handbook’s territory (its escalation-patterns chapter is forthcoming).

Practice

Exercise solutions

Solution ↑ Exercise

B. The database choice is a genuine intent decision the model cannot infer, so the reliable move is to surface it: AskUserQuestion with a few bounded options gets a fast, unambiguous answer and lets the agent continue on the right branch. A guesses — a reasonable default is still a coin flip on a decision with downstream lock-in (migrations, drivers, hosting). C infers intent from an accident of the environment; what is installed on a build machine is not a statement of what the project should use. D is the over-correction: failing throws away a recoverable situation that one bounded question would resolve. Escalation, not guessing and not giving up, is the pattern.

Solution ↑ Exercise

One AskUserQuestion call carries 1–4 questions; each question offers 2–4 options (each an option a label + description), plus a short header (≤12 characters) and a multiSelect flag. The response associates an answer with its question by mapping the question to the chosen option’s label{ "answers": { "<question text>": "<label>" } } — so the agent routes each selection back to the specific question it answers (a multiSelect answer returns as an array or a comma-joined string). Free-text is handled by offering an “Other” option and passing the typed text rather than the literal "Other".

Solution ↑ Exercise

A subagent cannot call AskUserQuestion — it is an explicit SDK limitation, and a subagent runs in an isolated context with no channel back to the user. So a subagent that discovers an ambiguous spec has no way to escalate: it must guess or fail, the precise outcome escalation exists to prevent. The fix is to restructure the decomposition so the part that needs a human stays with the agent that can reach one: have the coordinator resolve the open questions first (via AskUserQuestion, ideally during a plan-mode interview), then hand the subagent a fully-specified, unambiguous task. Delegate only after intent is pinned — never push an unresolved decision down to an agent that cannot ask about it.

Exam essentials