@ai-sdk/openai 3.0.138 → 3.0.140

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "3.0.138",
3
+ "version": "3.0.140",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.19",
40
- "@ai-sdk/provider-utils": "4.0.64"
40
+ "@ai-sdk/provider-utils": "4.0.66"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -262,7 +262,7 @@ async function convertFunctionToolResultOutput({
262
262
  }
263
263
 
264
264
  type ParallelToolResultGroup = {
265
- metadata: ParallelToolCallMetadata;
265
+ metadata: ParallelToolCallMetadata & { input: string };
266
266
  results: Array<LanguageModelV3ToolResultPart>;
267
267
  };
268
268
 
@@ -274,7 +274,9 @@ function hasSameParallelToolCall(
274
274
  first.itemId === second.itemId &&
275
275
  first.toolCallId === second.toolCallId &&
276
276
  first.toolName === second.toolName &&
277
- first.input === second.input &&
277
+ (first.input === undefined ||
278
+ second.input === undefined ||
279
+ first.input === second.input) &&
278
280
  first.count === second.count
279
281
  );
280
282
  }
@@ -332,6 +334,12 @@ function collectCompleteParallelToolResultGroups({
332
334
  continue;
333
335
  }
334
336
 
337
+ if (
338
+ existing.metadata.input === undefined &&
339
+ metadata.input !== undefined
340
+ ) {
341
+ existing.metadata = metadata;
342
+ }
335
343
  existing.results.set(metadata.index, part);
336
344
  }
337
345
  }
@@ -339,7 +347,11 @@ function collectCompleteParallelToolResultGroups({
339
347
  const completeGroups = new Map<string, ParallelToolResultGroup>();
340
348
 
341
349
  for (const [toolCallId, group] of pendingGroups) {
342
- if (group.invalid || group.results.size !== group.metadata.count) {
350
+ if (
351
+ group.invalid ||
352
+ group.results.size !== group.metadata.count ||
353
+ group.metadata.input === undefined
354
+ ) {
343
355
  continue;
344
356
  }
345
357
 
@@ -349,7 +361,7 @@ function collectCompleteParallelToolResultGroups({
349
361
 
350
362
  if (results.every(isNonNullable)) {
351
363
  completeGroups.set(toolCallId, {
352
- metadata: group.metadata,
364
+ metadata: { ...group.metadata, input: group.metadata.input },
353
365
  results,
354
366
  });
355
367
  }
@@ -17,7 +17,8 @@ export type ParallelToolCallMetadata = {
17
17
  itemId: string;
18
18
  toolCallId: string;
19
19
  toolName: string;
20
- input: string;
20
+ /** Retained only on the first child; older histories may repeat it. */
21
+ input?: string;
21
22
  index: number;
22
23
  count: number;
23
24
  };
@@ -36,7 +37,7 @@ export function getParallelToolCallMetadata({
36
37
  typeof metadata.itemId !== 'string' ||
37
38
  typeof metadata.toolCallId !== 'string' ||
38
39
  typeof metadata.toolName !== 'string' ||
39
- typeof metadata.input !== 'string' ||
40
+ (metadata.input !== undefined && typeof metadata.input !== 'string') ||
40
41
  typeof metadata.index !== 'number' ||
41
42
  !Number.isInteger(metadata.index) ||
42
43
  typeof metadata.count !== 'number' ||
@@ -129,7 +130,7 @@ export async function expandParallelToolCall({
129
130
  itemId,
130
131
  toolCallId: toolCall.toolCallId,
131
132
  toolName: toolCall.toolName,
132
- input: toolCall.input,
133
+ ...(index === 0 && { input: toolCall.input }),
133
134
  index,
134
135
  count: toolUses.length,
135
136
  } satisfies ParallelToolCallMetadata,