@ai-sdk/openai 4.0.0-canary.67 → 4.0.0-canary.68

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.0-canary.68
4
+
5
+ ### Patch Changes
6
+
7
+ - 94eba1b: fix(openai): round-trip `namespace` on function_call input items
8
+
9
+ When `tool_search` dispatches a deferred tool, the resulting `function_call` carries a `namespace` field identifying which deferred-tool group the model picked. `#14789` preserved this on the read side (`providerMetadata.openai.namespace`), but the write side still serialized `function_call` input items without `namespace`. Multi-step / multi-turn conversations then failed with `Missing namespace for function_call '<name>'. ... Round-trip the model's function_call item with its namespace field included.`
10
+
11
+ `convert-to-openai-responses-input.ts` now reads `namespace` from `providerOptions.openai.namespace` (or `providerMetadata.openai.namespace`) on `tool-call` parts and includes it on the serialized `function_call` item, mirroring how `itemId` is round-tripped.
12
+
3
13
  ## 4.0.0-canary.67
4
14
 
5
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2963,7 +2963,7 @@ async function convertToOpenAIResponsesInput({
2963
2963
  hasApplyPatchTool = false,
2964
2964
  customProviderToolNames
2965
2965
  }) {
2966
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2966
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
2967
2967
  let input = [];
2968
2968
  const warnings = [];
2969
2969
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3093,6 +3093,7 @@ async function convertToOpenAIResponsesInput({
3093
3093
  }
3094
3094
  case "tool-call": {
3095
3095
  const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
3096
+ const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
3096
3097
  if (hasConversation && id != null) {
3097
3098
  break;
3098
3099
  }
@@ -3116,7 +3117,7 @@ async function convertToOpenAIResponsesInput({
3116
3117
  type: "tool_search_call",
3117
3118
  id: id != null ? id : part.toolCallId,
3118
3119
  execution,
3119
- call_id: (_g = parsedInput.call_id) != null ? _g : null,
3120
+ call_id: (_l = parsedInput.call_id) != null ? _l : null,
3120
3121
  status: "completed",
3121
3122
  arguments: parsedInput.arguments
3122
3123
  });
@@ -3131,7 +3132,7 @@ async function convertToOpenAIResponsesInput({
3131
3132
  if (hasPreviousResponseId && store && id != null) {
3132
3133
  break;
3133
3134
  }
3134
- const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_h = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _h : false);
3135
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
3135
3136
  if (store && id != null && isProviderDefinedToolCall) {
3136
3137
  input.push({ type: "item_reference", id });
3137
3138
  break;
@@ -3202,7 +3203,8 @@ async function convertToOpenAIResponsesInput({
3202
3203
  type: "function_call",
3203
3204
  call_id: part.toolCallId,
3204
3205
  name: resolvedToolName,
3205
- arguments: serializeToolCallArguments2(part.input)
3206
+ arguments: serializeToolCallArguments2(part.input),
3207
+ ...namespace != null && { namespace }
3206
3208
  });
3207
3209
  break;
3208
3210
  }
@@ -3218,7 +3220,7 @@ async function convertToOpenAIResponsesInput({
3218
3220
  part.toolName
3219
3221
  );
3220
3222
  if (resolvedResultToolName === "tool_search") {
3221
- const itemId = (_k = (_j = (_i = part.providerOptions) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.itemId) != null ? _k : part.toolCallId;
3223
+ const itemId = (_p = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _p : part.toolCallId;
3222
3224
  if (store) {
3223
3225
  input.push({ type: "item_reference", id: itemId });
3224
3226
  } else if (part.output.type === "json") {
@@ -3259,7 +3261,7 @@ async function convertToOpenAIResponsesInput({
3259
3261
  break;
3260
3262
  }
3261
3263
  if (store) {
3262
- const itemId = (_n = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.itemId) != null ? _n : part.toolCallId;
3264
+ const itemId = (_s = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.itemId) != null ? _s : part.toolCallId;
3263
3265
  input.push({ type: "item_reference", id: itemId });
3264
3266
  } else {
3265
3267
  warnings.push({
@@ -3344,7 +3346,7 @@ async function convertToOpenAIResponsesInput({
3344
3346
  }
3345
3347
  case "custom": {
3346
3348
  if (part.kind === "openai.compaction") {
3347
- const providerOptions = (_o = part.providerOptions) == null ? void 0 : _o[providerOptionsName];
3349
+ const providerOptions = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName];
3348
3350
  const id = providerOptions == null ? void 0 : providerOptions.itemId;
3349
3351
  if (hasConversation && id != null) {
3350
3352
  break;
@@ -3391,7 +3393,7 @@ async function convertToOpenAIResponsesInput({
3391
3393
  }
3392
3394
  const output = part.output;
3393
3395
  if (output.type === "execution-denied") {
3394
- const approvalId = (_q = (_p = output.providerOptions) == null ? void 0 : _p.openai) == null ? void 0 : _q.approvalId;
3396
+ const approvalId = (_v = (_u = output.providerOptions) == null ? void 0 : _u.openai) == null ? void 0 : _v.approvalId;
3395
3397
  if (approvalId) {
3396
3398
  continue;
3397
3399
  }
@@ -3465,7 +3467,7 @@ async function convertToOpenAIResponsesInput({
3465
3467
  outputValue = output.value;
3466
3468
  break;
3467
3469
  case "execution-denied":
3468
- outputValue = (_r = output.reason) != null ? _r : "Tool call execution denied.";
3470
+ outputValue = (_w = output.reason) != null ? _w : "Tool call execution denied.";
3469
3471
  break;
3470
3472
  case "json":
3471
3473
  case "error-json":
@@ -3542,7 +3544,7 @@ async function convertToOpenAIResponsesInput({
3542
3544
  contentValue = output.value;
3543
3545
  break;
3544
3546
  case "execution-denied":
3545
- contentValue = (_s = output.reason) != null ? _s : "Tool call execution denied.";
3547
+ contentValue = (_x = output.reason) != null ? _x : "Tool call execution denied.";
3546
3548
  break;
3547
3549
  case "json":
3548
3550
  case "error-json":
@@ -7320,7 +7322,7 @@ var OpenAISkills = class {
7320
7322
  };
7321
7323
 
7322
7324
  // src/version.ts
7323
- var VERSION = true ? "4.0.0-canary.67" : "0.0.0-test";
7325
+ var VERSION = true ? "4.0.0-canary.68" : "0.0.0-test";
7324
7326
 
7325
7327
  // src/openai-provider.ts
7326
7328
  function createOpenAI(options = {}) {