Skip to main content
A host tool is a function of your harness that scripts call like any tool: ask the end user, call another model, start a sub-agent, read your database. Declare it in the toolset, then run a worker that executes it. The worker long-polls the calls to its tools, runs your handler, keeps the claim alive with heartbeats while it runs, and answers with the result, like a Temporal activity worker. It runs in your infrastructure; Rewind never connects to it.

The handler’s context

Failures

  • A thrown HostToolError is the tool’s failure: the script gets a ToolError with its message and data, and decides what to do. With retryable: true, a tool under the retry policy is called again later.
  • Any other exception fails the call too, with Name: message, and is reported to onError.
In the script
A worker that dies mid-call loses its claim when the heartbeats stop (60 seconds by default). Under the 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 becomes deferred, needs no heartbeat, and is answered later by its token, from any process. The run waits durably meanwhile.
The complete program is in 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.