Skip to main content

Function: toolCommit()

toolCommit(options?): ToolCommitBundle

Defined in: packages/core/src/utils/tool-commit.ts:86

Terminal-commit bundle for goal-shaped loops.

Spread onto Baleybot.create so hosts do not assemble latch / stopWhen / refuse-empty by hand. stopWhen is fuse OR successful commit result.

prepareStep leaves the model unconstrained while it is doing real work — step 0 and any step following a step that produced tool calls run with the full tool set. It only forces the commit tool when the model stalled: the previous step produced no tool calls and nothing has committed yet. (Mirror of the Swift ToolCommit.onEmptyTools nudge.) Forcing on every step would make the commit tool the only reachable tool and prevent the bot from ever touching its workspace tools.

Lifetime: one bundle per run

The commit latch is a closure variable and does not clear itself. A bundle is intended to be created per run. If you reuse one on a long-lived Baleybot, call ToolCommitBundle.reset before each subsequent run — otherwise the second run starts already-committed (prepareStep never nudges, and isCommitted() reports the first run's result).

Parameters

options?

ToolCommitOptions = {}

Returns

ToolCommitBundle

Example

const commit = toolCommit();
const bot = Baleybot.create({
tools: { ...workspaceTools, ...commit.tools },
stopWhen: commit.stopWhen,
prepareStep: commit.prepareStep,
});

// reusing the same bundle for a second run:
commit.reset();