Skip to main content

Function: withGoal()

withGoal<T>(tool): T

Defined in: packages/core/src/utils/with-goal.ts:57

Wrap a single tool definition so its inputSchema has a required goal string prepended. Idempotent — wrapping a tool that already declares goal returns it unchanged.

Accepts Baleybot ToolDefinition / ZodToolDefinition AND AI-SDK tool() outputs (which are duck-compatible — same {description, inputSchema, execute} shape, just without a name field).

Type Parameters

T

T extends ToolDefinition<(...args) => unknown> | ZodToolDefinition<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, unknown> | GoalWrappable

Parameters

tool

T

Returns

T