Skip to content

Commit 7781a25

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 9513a81 commit 7781a25

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
@@ -4,6 +4,8 @@ import type {
44
} from '@ai-sdk/provider';
55
import { asSchema, type ToolSet } from 'ai';
66

7+
// Mirrors the tool→LanguageModelV3FunctionTool mapping in the core AI SDK's
8+
// prepareToolsAndToolChoice (ai/src/prompt/prepare-tools-and-tool-choice.ts).
79
export async function toolsToModelTools(
810
tools: ToolSet
911
): Promise<Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>> {
@@ -25,6 +27,11 @@ export async function toolsToModelTools(
2527
name,
2628
description: tool.description,
2729
inputSchema: await asSchema(tool.inputSchema).jsonSchema,
30+
...(tool.inputExamples != null
31+
? { inputExamples: tool.inputExamples }
32+
: {}),
33+
providerOptions: tool.providerOptions,
34+
...(tool.strict != null ? { strict: tool.strict } : {}),
2835
};
2936
})
3037
);

0 commit comments

Comments
 (0)