Skip to content

Commit a113bad

Browse files
committed
fix(ai): forward tool strict mode in toolsToModelTools
The core AI SDK's `prepareToolsAndToolChoice` already forwards `tool.strict` when building `LanguageModelV2FunctionTool` objects, but `@workflow/ai`'s `toolsToModelTools` does not. This means tools with `strict: true` lose that flag when run through DurableAgent, causing providers that support strict schema validation to fall back to non-strict mode. Align with the AI SDK by conditionally spreading `strict` when the tool defines it.
1 parent bfb1a60 commit a113bad

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/ai/src/agent/tools-to-model-tools.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { LanguageModelV3FunctionTool } from '@ai-sdk/provider';
22
import { asSchema, type ToolSet } from 'ai';
33

4+
// Mirrors the tool→LanguageModelV3FunctionTool mapping in the core AI SDK's
5+
// prepareToolsAndToolChoice (ai/src/prompt/prepare-tools-and-tool-choice.ts).
46
export async function toolsToModelTools(
57
tools: ToolSet
68
): Promise<LanguageModelV3FunctionTool[]> {
@@ -10,6 +12,11 @@ export async function toolsToModelTools(
1012
name,
1113
description: tool.description,
1214
inputSchema: await asSchema(tool.inputSchema).jsonSchema,
15+
...(tool.inputExamples != null
16+
? { inputExamples: tool.inputExamples }
17+
: {}),
18+
providerOptions: tool.providerOptions,
19+
...(tool.strict != null ? { strict: tool.strict } : {}),
1320
}))
1421
);
1522
}

0 commit comments

Comments
 (0)