API Reference
whenToolCalled
function whenToolCalled(toolName): StopCondition;Defined in: stop/conditions.ts:47
Build a condition that stops as soon as a specific tool has been called this turn.
Parameters
| Parameter | Type | Description |
|---|---|---|
toolName | string | The name of the tool to watch for in this turn's results. |
Returns
A StopCondition that fires when toolName appears in
ctx.toolResults.
Example
// Stop the run the moment the model calls the "submit_answer" tool.
const stop = whenToolCalled("submit_answer");