@ai-sdk/openai 4.0.65 → 4.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@ import { shellArgsSchema } from '../tool/shell';
21
21
  import { toolSearchArgsSchema } from '../tool/tool-search';
22
22
  import { webSearchArgsSchema } from '../tool/web-search';
23
23
  import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
24
+ import { normalizeOpenAIJsonSchema } from '../normalize-openai-json-schema';
24
25
  import type {
25
26
  OpenAIResponsesAllowedTool,
26
27
  OpenAIResponsesFunctionTool,
@@ -147,6 +148,7 @@ export async function prepareResponsesTools({
147
148
  const openaiFunctionTool = prepareFunctionTool({
148
149
  tool,
149
150
  options: openaiOptions,
151
+ toolWarnings,
150
152
  async: resolveAsyncToolOption({
151
153
  value: openaiOptions?.async,
152
154
  supportsAsyncToolCalling,
@@ -627,19 +629,31 @@ function toAllowedToolResolution(
627
629
  function prepareFunctionTool({
628
630
  tool,
629
631
  options,
632
+ toolWarnings,
630
633
  async,
631
634
  }: {
632
635
  tool: LanguageModelV4FunctionTool;
633
636
  options: OpenAIToolOptions | undefined;
637
+ toolWarnings: SharedV4Warning[];
634
638
  async: boolean | undefined;
635
639
  }): OpenAIResponsesFunctionTool {
636
640
  const deferLoading = options?.deferLoading;
641
+ const normalizedInputSchema = normalizeOpenAIJsonSchema(tool.inputSchema);
642
+ const normalizedOutputSchema =
643
+ options?.outputSchema != null
644
+ ? normalizeOpenAIJsonSchema(options.outputSchema as JSONSchema7)
645
+ : undefined;
646
+
647
+ toolWarnings.push(
648
+ ...normalizedInputSchema.warnings,
649
+ ...(normalizedOutputSchema?.warnings ?? []),
650
+ );
637
651
 
638
652
  return {
639
653
  type: 'function',
640
654
  name: tool.name,
641
655
  description: tool.description,
642
- parameters: tool.inputSchema,
656
+ parameters: normalizedInputSchema.schema,
643
657
  ...(async != null ? { async } : {}),
644
658
  ...(tool.strict != null ? { strict: tool.strict } : {}),
645
659
  ...(deferLoading != null ? { defer_loading: deferLoading } : {}),
@@ -647,7 +661,7 @@ function prepareFunctionTool({
647
661
  ? { allowed_callers: options.allowedCallers }
648
662
  : {}),
649
663
  ...(options?.outputSchema != null
650
- ? { output_schema: options.outputSchema as JSONSchema7 }
664
+ ? { output_schema: normalizedOutputSchema?.schema }
651
665
  : {}),
652
666
  };
653
667
  }