Use tools when an agent needs to read application data, call an internal service, or perform an action. The Agent SDK validates tool boundaries and runs tool code inside your application.
defineTool() accepts a description, optional JSON parameters, runtime validators, a timeout, and an execute() function.
If the timeout expires, the runtime aborts 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
Set execute: 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:
Progress is available through tool.preliminary_result events and the step’s preliminaryResults.
If one model turn can safely call several independent tools, configure a concurrency limit:
The runtime preserves tool-result message order even when local execution overlaps.
Last modified on July 26, 2026