🧩canUseTool Callback
Also known as canUseTool, can_use_tool, Agent SDK approval callback, Claude Agent SDK canUseTool
Your own function that decides a tool call when nothing else has.
Think of it like
It is like a helper who calls you to ask, may I do this?
Example
Mia's web app shows an Approve button when the agent wants to write a file. Her canUseTool callback waits for the click.
Why it matters
It is how a person, or your own rules, stay in charge of what the agent does.
Definition
Example code
typescript
canUseTool: async (tool, input) =>
tool === "Bash" ? { behavior: "deny", message: "No shell" }
: { behavior: "allow", updatedInput: input }Common mistake
Key takeaways
- 1The last check. After rules and mode.
- 2allow or deny. With a reason.
- 3Can change input. updatedInput.