1. Add the hook
A hook atbefore_tool_call sees the tool name and its input
before the tool runs. A client processor means “stop and ask my application”.
The profile probably has hooks already: unless someone opted out, it was
created with the 13 default approvals. The
hook list you send replaces the whole list, so read what’s there and append
yours. PATCH also wants the version you read as expectedVersion, which
keeps two editors from overwriting each other:
approve-writes last.
Send a list without the defaults and they’re gone: nothing merges them back,
and hooks: [] means no hooks at all. A 409 means someone else edited the
profile between your read and your write; run it again.
A hook doesn’t grant anything. Roles are checked first, so a tool the roles
leave out never reaches the hook. If you came from
Narrow an agent’s permissions, that role only
allows http.request for GET. Drop the where from that entry; the hook is
what stops writes now, and it can ask you instead of refusing outright.
2. Trigger it
Ask the agent for something it can only do by writing:3. Find what’s waiting
The turn runs in the background, so poll the thread until its wait shows up:GET /v1/threads?state=waiting lists every thread
parked on a person, a page at a time: that’s your approval queue.
pendingWaits is the list of calls stopped and waiting for an answer. On an
approval like this one, each entry carries a toolName, an expiresAt, and
asks: one entry per hook that asked about the call, each with its hookId,
processor, reason, and description. Every hook that asked shares this one
wait, so a single answer settles them all, and the wait’s own hookId is the
first hook that asked. For some provider tools there’s also a preview, a
readable summary built for the approver.
The same thread view also has the raw input the agent is about to send:
4. Decide
allow releases the call and the turn picks up where it stopped. deny drops
it and the model is told why, so give a reason worth reading. Two more things
an allow can carry:
"updatedInput": { … }runs the call with input you edited instead. The call’surl,agent, andmodelhooks answer again on the new input."grant": {}stops the asking for this tool in this thread: laterhttp.requestcalls here skip the person, though any other hook can still deny them.usesandexpiresAtbound it.
Check it worked
hook_decision ask is the hook deciding
to ask you instead of answering for you. wait_created is the turn stopping.
wait_resolved is your answer; its waitResult holds the decision and the
reason you sent. After that, the tool_result shows the call finally running.
Deny instead and that tool_result carries failureCode: hook_denied, with a
failureText of Denied by the approver: followed by your reason. See
Thread events.
When it goes sideways
- Nobody answers. The wait expires after
asyncTimeoutMs(24 hours for aclienthook, which is also the maximum) and the call is dropped withwait_expired. Silence is always a no;onFailurecovers hook processors that break, not people who don’t answer. - Another check said no first. If a slow
urloragenthook on the same call denies while you’re deciding, your wait closes unanswered with statuswithdrawn, and resolving it gets409 Conflict. The turn result (GET /v1/threads/{threadId}/turns/{turnId}/result) lists it underwithdrawn, with areasonnaming who denied. - Two people answer. A wait settles once: a second, different answer gets
409 Conflict. Retrying your own identical request is safe. - You edit the profile while a call is waiting. Nothing changes. The turn is running against the snapshot it started with, so your edit applies to the next turn, not this one.
Where next
Hooks reference
Points, processors, decisions, and the defaults.
Run on a schedule
Same agent, no one at the keyboard.