@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.
@@ -3703,6 +3703,7 @@ async function convertToOpenAIResponsesInput({
3703
3703
  fileIdPrefixes,
3704
3704
  passThroughUnsupportedFiles = false,
3705
3705
  store,
3706
+ isReasoningModel = false,
3706
3707
  hasConversation = false,
3707
3708
  hasPreviousResponseId = false,
3708
3709
  configurationUpdateUnsupportedReason,
@@ -3875,6 +3876,7 @@ async function convertToOpenAIResponsesInput({
3875
3876
  }
3876
3877
  case "assistant": {
3877
3878
  const reasoningMessages = {};
3879
+ let hasPrecedingReasoning = false;
3878
3880
  for (const part of content) {
3879
3881
  switch (part.type) {
3880
3882
  case "text": {
@@ -3884,7 +3886,8 @@ async function convertToOpenAIResponsesInput({
3884
3886
  if (hasConversation && id != null) {
3885
3887
  break;
3886
3888
  }
3887
- if (store && id != null) {
3889
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
3890
+ if (store && canUseItemId) {
3888
3891
  input.push({ type: "item_reference", id });
3889
3892
  break;
3890
3893
  }
@@ -3892,7 +3895,7 @@ async function convertToOpenAIResponsesInput({
3892
3895
  ...explicitMessageItemType && { type: "message" },
3893
3896
  role: "assistant",
3894
3897
  content: [{ type: "output_text", text: part.text }],
3895
- id,
3898
+ id: canUseItemId ? id : void 0,
3896
3899
  ...phase != null && { phase }
3897
3900
  });
3898
3901
  break;
@@ -4126,6 +4129,7 @@ async function convertToOpenAIResponsesInput({
4126
4129
  break;
4127
4130
  }
4128
4131
  case "reasoning": {
4132
+ hasPrecedingReasoning = true;
4129
4133
  const providerOptions2 = await (0, import_provider_utils27.parseProviderOptions)({
4130
4134
  provider: providerOptionsName,
4131
4135
  providerOptions: part.providerOptions,
@@ -6346,6 +6350,7 @@ var OpenAIResponsesLanguageModel = class {
6346
6350
  fileIdPrefixes: this.config.fileIdPrefixes,
6347
6351
  passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
6348
6352
  store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
6353
+ isReasoningModel,
6349
6354
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
6350
6355
  hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
6351
6356
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -7186,6 +7191,11 @@ var OpenAIResponsesLanguageModel = class {
7186
7191
  id: value.item.call_id,
7187
7192
  toolName
7188
7193
  });
7194
+ controller.enqueue({
7195
+ type: "tool-input-delta",
7196
+ id: value.item.call_id,
7197
+ delta: '"'
7198
+ });
7189
7199
  } else if (value.item.type === "web_search_call") {
7190
7200
  ongoingToolCalls[value.output_index] = {
7191
7201
  toolName: toolNameMapping.toCustomToolName(
@@ -7474,6 +7484,11 @@ var OpenAIResponsesLanguageModel = class {
7474
7484
  const toolName = toolNameMapping.toCustomToolName(
7475
7485
  value.item.name
7476
7486
  );
7487
+ controller.enqueue({
7488
+ type: "tool-input-delta",
7489
+ id: value.item.call_id,
7490
+ delta: '"'
7491
+ });
7477
7492
  controller.enqueue({
7478
7493
  type: "tool-input-end",
7479
7494
  id: value.item.call_id
@@ -7800,7 +7815,7 @@ var OpenAIResponsesLanguageModel = class {
7800
7815
  controller.enqueue({
7801
7816
  type: "tool-input-delta",
7802
7817
  id: toolCall.toolCallId,
7803
- delta: value.delta
7818
+ delta: escapeJSONDelta(value.delta)
7804
7819
  });
7805
7820
  }
7806
7821
  } else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {