@ai-sdk/openai 3.0.125 → 3.0.127

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.
@@ -3758,6 +3758,7 @@ async function convertToOpenAIResponsesInput({
3758
3758
  fileIdPrefixes,
3759
3759
  passThroughUnsupportedFiles = false,
3760
3760
  store,
3761
+ isReasoningModel = false,
3761
3762
  hasConversation = false,
3762
3763
  hasPreviousResponseId = false,
3763
3764
  configurationUpdateUnsupportedReason,
@@ -3930,6 +3931,7 @@ async function convertToOpenAIResponsesInput({
3930
3931
  }
3931
3932
  case "assistant": {
3932
3933
  const reasoningMessages = {};
3934
+ let hasPrecedingReasoning = false;
3933
3935
  for (const part of content) {
3934
3936
  switch (part.type) {
3935
3937
  case "text": {
@@ -3939,7 +3941,8 @@ async function convertToOpenAIResponsesInput({
3939
3941
  if (hasConversation && id != null) {
3940
3942
  break;
3941
3943
  }
3942
- if (store && id != null) {
3944
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
3945
+ if (store && canUseItemId) {
3943
3946
  input.push({ type: "item_reference", id });
3944
3947
  break;
3945
3948
  }
@@ -3947,7 +3950,7 @@ async function convertToOpenAIResponsesInput({
3947
3950
  ...explicitMessageItemType && { type: "message" },
3948
3951
  role: "assistant",
3949
3952
  content: [{ type: "output_text", text: part.text }],
3950
- id,
3953
+ id: canUseItemId ? id : void 0,
3951
3954
  ...phase != null && { phase }
3952
3955
  });
3953
3956
  break;
@@ -4181,6 +4184,7 @@ async function convertToOpenAIResponsesInput({
4181
4184
  break;
4182
4185
  }
4183
4186
  case "reasoning": {
4187
+ hasPrecedingReasoning = true;
4184
4188
  const providerOptions2 = await parseProviderOptions7({
4185
4189
  provider: providerOptionsName,
4186
4190
  providerOptions: part.providerOptions,
@@ -6430,6 +6434,7 @@ var OpenAIResponsesLanguageModel = class {
6430
6434
  fileIdPrefixes: this.config.fileIdPrefixes,
6431
6435
  passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
6432
6436
  store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
6437
+ isReasoningModel,
6433
6438
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
6434
6439
  hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
6435
6440
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -7270,6 +7275,11 @@ var OpenAIResponsesLanguageModel = class {
7270
7275
  id: value.item.call_id,
7271
7276
  toolName
7272
7277
  });
7278
+ controller.enqueue({
7279
+ type: "tool-input-delta",
7280
+ id: value.item.call_id,
7281
+ delta: '"'
7282
+ });
7273
7283
  } else if (value.item.type === "web_search_call") {
7274
7284
  ongoingToolCalls[value.output_index] = {
7275
7285
  toolName: toolNameMapping.toCustomToolName(
@@ -7558,6 +7568,11 @@ var OpenAIResponsesLanguageModel = class {
7558
7568
  const toolName = toolNameMapping.toCustomToolName(
7559
7569
  value.item.name
7560
7570
  );
7571
+ controller.enqueue({
7572
+ type: "tool-input-delta",
7573
+ id: value.item.call_id,
7574
+ delta: '"'
7575
+ });
7561
7576
  controller.enqueue({
7562
7577
  type: "tool-input-end",
7563
7578
  id: value.item.call_id
@@ -7884,7 +7899,7 @@ var OpenAIResponsesLanguageModel = class {
7884
7899
  controller.enqueue({
7885
7900
  type: "tool-input-delta",
7886
7901
  id: toolCall.toolCallId,
7887
- delta: value.delta
7902
+ delta: escapeJSONDelta(value.delta)
7888
7903
  });
7889
7904
  }
7890
7905
  } else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {