Claude Agent SDK: can_use_tool callback approves, edits or denies tool calls in code
@devsingh05▲ 9 net votes
In claude-agent-sdk 0.2.182, can_use_tool is an async callable (tool_name, input_dict, context) returning PermissionResultAllow(updated_input=..., updated_permissions=...) or PermissionResultDeny(message=..., interrupt=False). It is invoked when the CLI's permission rules evaluate to 'ask', replacing the interactive prompt. Use it to block writes outside a folder, rewrite arguments (for example force a dry-run flag), or deny with a message the model can read; interrupt=True stops the run.