Learning resourcesReviewed · Anthropic

Claude Agent SDK: Handle approvals and user input

This Claude Agent SDK guide teaches developers to add approvals and clarifying questions to agent applications, but its approval callback does not intercept every tool call. It provides Python and TypeScript examples for canUseTool, permission responses and AskUserQuestion.

Researched 24 Nov 2026

In short.

Handle approvals and user input is a guide for developers adding human decisions to Claude Agent SDK applications, but earlier permission rules can resolve tool calls before its callback runs. It explains approval responses, modified tool inputs, remembered permissions and structured answers to Claude's questions. Developers must supply their own interface and account for permission modes, version requirements and long waits. The examples were not executed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete page at [https://code.claude.com/docs/en/agent-sdk/user-input.md], including its examples, permission warnings, version notes, Python workaround, question limits and descriptions of related approaches. Linked pages, package implementations and release histories are excluded. Installation, authentication, pricing, licensing and detailed deferred-session implementation are not established here. No examples were executed.

The overview

Identity

The resource is the Claude Code documentation page Handle approvals and user input at [https://code.claude.com/docs/en/agent-sdk/user-input.md]. It covers how an application presents Claude's requests for tool permission and clarification, then returns the user's decision to the Agent SDK.

Its scope is this interaction feature, rather than a complete introduction to installing, authenticating or deploying the SDK.

Assessment

The guide is useful when an existing agent application needs approval controls or questions during a task. Its concrete callback signatures, response objects and examples explain both the user interaction and the data the SDK expects.

The main design constraint is that canUseTool is one part of a wider permission system. Treating it as a universal approval gate would miss calls resolved earlier. The page identifies PreToolUse hooks as a way to inspect calls that bypass the callback, but detailed hook configuration is outside this page.

Users

The primary audience is Python or TypeScript developers building interactive agents, including terminal tools and applications with web or mobile interfaces. Beginners get an explanation of approval requests versus clarifying questions; experienced developers get response schemas and permission-flow caveats.

Readers need some familiarity with asynchronous programming and application interfaces. The resource provides integration examples rather than a ready-made approval interface.

Capabilities

The guide shows how to approve a tool call, change its inputs before execution, deny it with feedback, and apply suggested permission rules to avoid repeated prompts. It also describes redirecting the agent through streaming input.

For clarifying questions, it covers single and multiple selections, custom answers and a general free-text response. TypeScript applications can request optional Markdown or HTML previews for question options. The application remains responsible for displaying requests and collecting answers.

Using it

Requirements

The examples use claude_agent_sdk in Python and @anthropic-ai/claude-agent-sdk in TypeScript. An application needs a query configuration, an asynchronous permission callback and its own mechanism for collecting user input.

If an explicit tools array restricts available tools, it must include AskUserQuestion for Claude to ask clarifying questions. Installation steps, authentication requirements and a general minimum SDK version are not established by this page; individual features have specific version notes.

Mechanism

The callback receives the tool name, its input and additional context. For ordinary tool requests, it returns allow or deny, optionally supplying changed inputs or permission updates. Denial messages are visible to Claude and may influence its next approach.

AskUserQuestion uses the same callback but needs a separate handler. The application returns the original questions together with answers keyed by the exact question text. Selected option labels or custom text become the answer values.

Execution pauses while the callback is pending, potentially indefinitely. Earlier deny rules, permission modes and allow rules can resolve calls before this callback; some configurations, including dontAsk, do not invoke it. For waits that must survive process exit, the page recommends a PreToolUse hook returning defer and later resumption from a persisted session.

Setup

Pass can_use_tool through Python's ClaudeAgentOptions or canUseTool through TypeScript query options. Route requests whose tool name is AskUserQuestion to a question handler, and send other requests to the application's approval interface.

For questions, preserve the original questions array and construct the answers mapping. Multiple selections can use arrays of labels or comma-joined labels. Use response only for a general reply that replaces the per-question answer presentation.

The Python interactive examples use a prompt stream and a dummy PreToolUse hook, described as a required workaround to keep the stream open for can_use_tool. Its applicability to a particular installed version was not assessed.

Example

One example asks Claude to create a temporary file and then delete it. When approval is requested, the application displays the tool and its parameters, asks for y/n input, and returns an allow or deny result. Only y permits the action; other input denies it.

A second example asks Claude to help choose a technology stack for a mobile application. Its handler displays generated questions and options, accepts numbered choices or custom text, and returns answers under the original question strings. These are illustrative examples, with no execution results established here.

Assessment & evidence

Limitations

AskUserQuestion is unavailable to subagents spawned through the Agent tool. Each call supports one to four questions, each with two to four options. Applications cannot insert their own questions into Claude's generated question flow; those interactions need separate application logic.

The TypeScript callback context includes an AbortSignal, while the Python signal field is described as reserved for future use. Long response times require deliberate process-lifetime or deferred-session handling.

The complete clarification examples automatically approve other tools, so they do not demonstrate an approval policy for those operations. The approve-with-changes example replaces text in a command string; that operation alone should not be treated as a complete sandbox.

Fit and tradeoffs

For occasional approvals and short questions during agent work, the documented callbacks provide a defined request-and-response format. This reduces the need to invent an interaction protocol, although developers still build the interface and decide how permissions should behave.

A key tradeoff is between approving one operation and remembering a permission rule. The latter can remove future prompts for matching calls, so its scope and persistence matter. The page explains how to return suggested rules but does not establish which rules are appropriate for a particular application.

Alternative interaction approaches

Within the SDK, the page recommends streaming input for follow-up messages, extra context and interruptions during ongoing work. That is a better match for continuous conversation than relying only on approval checkpoints.

It describes custom tools as an option for forms, multi-step workflows, external approval systems and domain-specific interactions. They provide more control but require more implementation work. The linked implementation guides and competing SDKs are outside this resource's coverage.

Evidence and confidence

The documentation supports the described interfaces through explanations, parameter tables, response examples and Python and TypeScript snippets. The original page address is [https://code.claude.com/docs/en/agent-sdk/user-input.md].

The examples were not executed. Runtime compatibility, cancellation behavior, successful deferred resumption and reliability in a deployed application remain unverified. The page provides no benchmarks or independent validation.

Access & freshness

Costs

The page gives no SDK access price, model usage rates, hosting costs or notification-service charges. Total implementation and operating costs are unknown. It supplies no usage measurements or cost estimates.

Rights

The page does not state licensing or redistribution terms for its documentation, example code or SDK packages. Those rights are unknown from this resource alone.

Freshness and version notes

The page was captured on 24 November 2026 at 15:13:21 UTC. A publication date, last-update date and latest SDK release are not established by the supplied text.

The page says Claude Code versions before v2.1.207 rejected allow responses that omitted updatedInput. Its Python remembered-permission example requires claude-agent-sdk 0.1.80 or later. The TypeScript suppressAlwaysAllowRule hint requires Agent SDK v0.3.268 or later, and the Python context does not carry that hint. These are feature-specific notes rather than a single compatibility guarantee.

Before adopting

Confirm the installed SDK and Claude Code versions, then examine which permission rules and modes can resolve calls before the callback. Decide whether user waits can remain inside a running process or require deferred resumption.

Replace the clarification examples' automatic approval of other tools with the intended approval handling. For remembered permissions, inspect rule destinations and respect the TypeScript suppressAlwaysAllowRule hint when present. Exercise approval, denial, modified inputs, multiple selections, custom answers and interrupted waits in the target application before relying on the integration.

Evidence for this report

selected-page.txtselected · checked 2026-11-24