The handler’s context
Failures
- A thrown
HostToolErroris the tool’s failure: the script gets aToolErrorwith itsmessageanddata, and decides what to do. Withretryable: true, a tool under theretrypolicy is called again later. - Any other exception fails the call too, with
Name: message, and is reported toonError.
In the script
retry policy,
the call is given to another worker with the same idempotency key, up to 5 attempts. Under at_most_once, it fails
with outcomeUnknown: true: declare it for a tool that must never run twice, such as asking the user a question.
Answers that take days
A handler can defer its answer: the call becomesdeferred, needs no heartbeat, and is answered later by its token,
from any process. The run waits durably meanwhile.
examples/host-tools.
Options
A refused key (401, 403) stops the worker:
worker.done rejects. Other failures are reported to onError and
retried. A worker holding an end user’s token, instead of a key, claims only the calls of that end user’s runs.