Function: hasToolResult()
hasToolResult(
toolName,predicate?):StopCondition
Defined in: packages/core/src/utils/stop-conditions.ts:109
Stop when a specific tool has been called
Optionally accepts a predicate to inspect the tool result. When provided, only stops if the predicate returns true — allowing you to distinguish between successful and failed tool executions.
Parameters
toolName
string
Name of the tool to watch for
predicate?
(result) => boolean
Optional function to inspect the result. Receives the tool's return value. Return true to stop, false to continue.
Returns
StopCondition that triggers when the tool is called (and predicate passes)
Examples
const bot = new Baleybot({
stopWhen: hasToolResult('submit_answer'),
});
const bot = new Baleybot({
stopWhen: hasToolResult('create_space', (result) => !result?.error),
});
const bot = new Baleybot({
stopWhen: hasToolResult('analyze', (result) => result?.confidence > 0.9),
});