[DOCS] canUseTool callback documentation states two arguments but both SDKs use three
Documentation Type
Missing documentation (feature not documented)
Documentation Location
https://platform.claude.com/docs/en/agent-sdk/user-input
Section/Topic
"Handle tool approval requests" section
Current Documentation
The prose states:
Once you've passed a canUseTool callback in your query options, it fires when Claude wants to use a tool that isn't auto-approved. Your callback receives two arguments:
Followed by a table listing only toolName and input.
However, the Python code example immediately below shows:
async def can_use_tool(
tool_name: str, input_data: dict, context: ToolPermissionContext
) -> PermissionResultAllow | PermissionResultDeny:
And the TypeScript SDK Reference defines CanUseTool as:
type CanUseTool = (
toolName: string,
input: ToolInput,
options: {
signal: AbortSignal;
}
) => ...
What's Wrong or Missing?
The prose explicitly states the callback receives two arguments, but:
- The Python code examples throughout the page show three arguments (including
context: ToolPermissionContext) - The TypeScript SDK Reference confirms three arguments (including
optionswithAbortSignal)
Users following the text description may write callbacks with only two parameters, resulting in:
TypeErrorin Python (missing positional argumentcontext)- TypeScript users missing access to the
AbortSignalfor cancellation handling
Suggested Improvement
Update the text and table to document all three arguments:
Your callback receives three arguments:
| Argument | Description |
|----------|-------------|
| toolName | The name of the tool Claude wants to use (e.g., "Bash", "Write", "Edit") |
| input | The parameters Claude is passing to the tool. Contents vary by tool. |
| context/options | Context object containing metadata. In Python: ToolPermissionContext. In TypeScript: { signal: AbortSignal } for cancellation handling. |
Impact
High - Prevents users from using a feature
Additional Context
- Mirror location:
platform.claude.com/docs/en/agent-sdk/user-input.md - Python SDK Reference: https://platform.claude.com/docs/en/agent-sdk/python
- TypeScript SDK Reference: https://platform.claude.com/docs/en/agent-sdk/typescript#canusetool
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗