@@ -95,7 +95,7 @@ class AgentDefinition:
9595 initialPrompt : str | None = None # noqa: N815
9696 maxTurns : int | None = None # noqa: N815
9797 background : bool | None = None
98- effort : Literal ["low" , "medium" , "high" , "max" ] | int | None = None
98+ effort : Literal ["low" , "medium" , "high" , "xhigh" , " max" ] | int | None = None
9999 permissionMode : PermissionMode | None = None # noqa: N815
100100
101101
@@ -181,9 +181,29 @@ class ToolPermissionContext:
181181 ) # Permission suggestions from CLI
182182 tool_use_id : str | None = None
183183 """Unique identifier for this specific tool call within the assistant message.
184- Multiple tool calls in the same assistant message will have different tool_use_ids."""
184+ Multiple tool calls in the same assistant message will have different tool_use_ids.
185+
186+ Always a non-empty string when delivered to a ``can_use_tool`` callback (the
187+ wire protocol guarantees it); the ``Optional`` is only for dataclass
188+ field-ordering compatibility, so callers do not need to handle ``None``."""
185189 agent_id : str | None = None
186190 """If running within the context of a sub-agent, the sub-agent's ID."""
191+ blocked_path : str | None = None
192+ """The file path that triggered the permission request, if applicable.
193+ For example, when a Bash command tries to access a path outside allowed directories."""
194+ decision_reason : str | None = None
195+ """Explains why this permission request was triggered.
196+ When a PreToolUse hook returns ``permissionDecision: "ask"`` with a
197+ ``permissionDecisionReason``, that reason is forwarded here."""
198+ title : str | None = None
199+ """Full permission prompt sentence (e.g. "Claude wants to read foo.txt").
200+ Use this as the primary prompt text when present instead of reconstructing
201+ from tool name + input."""
202+ display_name : str | None = None
203+ """Short noun phrase for the tool action (e.g. "Read file"), suitable for
204+ button labels or compact UI."""
205+ description : str | None = None
206+ """Human-readable subtitle for the permission UI."""
187207
188208
189209# Match TypeScript's PermissionResult structure
@@ -370,7 +390,7 @@ class PreToolUseHookSpecificOutput(TypedDict):
370390 """Hook-specific output for PreToolUse events."""
371391
372392 hookEventName : Literal ["PreToolUse" ]
373- permissionDecision : NotRequired [Literal ["allow" , "deny" , "ask" ]]
393+ permissionDecision : NotRequired [Literal ["allow" , "deny" , "ask" , "defer" ]]
374394 permissionDecisionReason : NotRequired [str ]
375395 updatedInput : NotRequired [dict [str , Any ]]
376396 additionalContext : NotRequired [str ]
@@ -381,7 +401,17 @@ class PostToolUseHookSpecificOutput(TypedDict):
381401
382402 hookEventName : Literal ["PostToolUse" ]
383403 additionalContext : NotRequired [str ]
404+ updatedToolOutput : NotRequired [Any ]
405+ """Replaces the tool output before it is sent to the model.
406+
407+ For built-in tools (Bash, Read, Edit, etc.) the value must match the tool's
408+ output schema (e.g. ``{"stdout": ..., "stderr": ..., "interrupted": ...}``
409+ for Bash); a mismatched shape is rejected and the original output is kept.
410+ """
384411 updatedMCPToolOutput : NotRequired [Any ]
412+ """Replaces the output for MCP tools only. Prefer ``updatedToolOutput``,
413+ which works for all tools.
414+ """
385415
386416
387417class PostToolUseFailureHookSpecificOutput (TypedDict ):
@@ -1074,6 +1104,20 @@ class MirrorErrorMessage(SystemMessage):
10741104 error : str = ""
10751105
10761106
1107+ @dataclass
1108+ class DeferredToolUse :
1109+ """Tool use that was deferred by a PreToolUse hook returning ``"defer"``.
1110+
1111+ When a PreToolUse hook returns ``permissionDecision: "defer"``, the run
1112+ stops and the result message carries the deferred tool call here so the
1113+ caller can inspect it and decide whether to resume.
1114+ """
1115+
1116+ id : str
1117+ name : str
1118+ input : dict [str , Any ]
1119+
1120+
10771121@dataclass
10781122class ResultMessage :
10791123 """Result message with cost and usage information."""
@@ -1091,6 +1135,7 @@ class ResultMessage:
10911135 structured_output : Any = None
10921136 model_usage : dict [str , Any ] | None = None
10931137 permission_denials : list [Any ] | None = None
1138+ deferred_tool_use : DeferredToolUse | None = None
10941139 errors : list [str ] | None = None
10951140 uuid : str | None = None
10961141
@@ -1669,10 +1714,15 @@ class ClaudeAgentOptions:
16691714 """
16701715
16711716 can_use_tool : CanUseTool | None = None
1672- """Custom permission handler for controlling tool usage .
1717+ """Custom permission handler for tool calls that would otherwise prompt the user .
16731718
1674- Called before each tool execution to determine if it should be allowed,
1675- denied, or prompt the user.
1719+ Invoked when the CLI's permission rules evaluate to "ask" for a tool call —
1720+ it is the SDK replacement for the interactive permission prompt. It is *not*
1721+ invoked for tool calls already permitted by ``allowed_tools``,
1722+ ``permission_mode`` (e.g. ``"acceptEdits"`` / ``"bypassPermissions"``), or
1723+ ``permissions.allow`` rules in settings, since those never reach a prompt.
1724+ To observe or gate *every* tool call regardless of permission rules, use a
1725+ ``PreToolUse`` hook via ``hooks`` instead.
16761726 """
16771727
16781728 hooks : dict [HookEvent , list [HookMatcher ]] | None = None
@@ -1783,14 +1833,16 @@ class ClaudeAgentOptions:
17831833 See https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking.
17841834 """
17851835
1786- effort : Literal ["low" , "medium" , "high" , "max" ] | None = None
1836+ effort : Literal ["low" , "medium" , "high" , "xhigh" , " max" ] | None = None
17871837 """Controls how much effort Claude puts into its response.
17881838
17891839 Works with adaptive thinking to guide thinking depth.
17901840
17911841 - ``"low"`` — Minimal thinking, fastest responses.
17921842 - ``"medium"`` — Moderate thinking.
17931843 - ``"high"`` — Deep reasoning (default).
1844+ - ``"xhigh"`` — Extended reasoning depth (Opus 4.7 only; falls back to
1845+ ``"high"`` on other models).
17941846 - ``"max"`` — Maximum effort.
17951847
17961848 See https://docs.anthropic.com/en/docs/build-with-claude/effort.
@@ -1861,6 +1913,10 @@ class SDKControlPermissionRequest(TypedDict):
18611913 # TODO: Add PermissionUpdate type here
18621914 permission_suggestions : list [Any ] | None
18631915 blocked_path : str | None
1916+ decision_reason : NotRequired [str ]
1917+ title : NotRequired [str ]
1918+ display_name : NotRequired [str ]
1919+ description : NotRequired [str ]
18641920 tool_use_id : str
18651921 agent_id : NotRequired [str ]
18661922
0 commit comments