Define a local tool
defineTool() accepts a description, optional JSON parameters, runtime validators, a timeout, and an execute() function.
context.signal, marks the run as failed, and rethrows the timeout error.
Schemas can be functions or objects exposing parse() or safeParse(). Invalid model arguments and invalid tool results fail before they cross the tool boundary.
Run work in your application
Setexecute: false when your application, rather than the SDK process, performs the work. Continue the paused run with the result in toolOutputs.
For an interactive tool, return null from onToolCalled. After continuation, onResponseReceived can validate or transform the supplied response.
Publish progress
An async generator can yield preliminary results before returning one final result:tool.preliminary_result events and the step’s preliminaryResults.