Open Agent Loops
API Reference

whenToolCalled

@open-agent-loops/core


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

ParameterTypeDescription
toolNamestringThe name of the tool to watch for in this turn's results.

Returns

StopCondition

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");

See

StopContext

On this page