@ai-sdk/openai 2.0.134 → 2.0.135

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.
@@ -2719,6 +2719,7 @@ async function convertToOpenAIResponsesInput({
2719
2719
  explicitMessageItemType = false,
2720
2720
  fileIdPrefixes,
2721
2721
  store,
2722
+ isReasoningModel = false,
2722
2723
  configurationUpdateUnsupportedReason,
2723
2724
  hasLocalShellTool = false,
2724
2725
  webSearchToolName
@@ -2872,12 +2873,14 @@ async function convertToOpenAIResponsesInput({
2872
2873
  case "assistant": {
2873
2874
  const reasoningMessages = {};
2874
2875
  const toolCallParts = {};
2876
+ let hasPrecedingReasoning = false;
2875
2877
  for (const part of content) {
2876
2878
  switch (part.type) {
2877
2879
  case "text": {
2878
2880
  const id = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.itemId;
2879
2881
  const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
2880
- if (store && id != null) {
2882
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2883
+ if (store && canUseItemId) {
2881
2884
  input.push({ type: "item_reference", id });
2882
2885
  break;
2883
2886
  }
@@ -2885,7 +2888,7 @@ async function convertToOpenAIResponsesInput({
2885
2888
  ...explicitMessageItemType && { type: "message" },
2886
2889
  role: "assistant",
2887
2890
  content: [{ type: "output_text", text: part.text }],
2888
- id,
2891
+ id: canUseItemId ? id : void 0,
2889
2892
  ...phase != null && { phase }
2890
2893
  });
2891
2894
  break;
@@ -2897,7 +2900,8 @@ async function convertToOpenAIResponsesInput({
2897
2900
  }
2898
2901
  const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
2899
2902
  const isAsync = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.async;
2900
- if (store && id != null) {
2903
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2904
+ if (store && canUseItemId) {
2901
2905
  input.push({ type: "item_reference", id });
2902
2906
  break;
2903
2907
  }
@@ -2927,7 +2931,7 @@ async function convertToOpenAIResponsesInput({
2927
2931
  name: part.toolName,
2928
2932
  arguments: JSON.stringify(part.input),
2929
2933
  ...isAsync != null && { async: isAsync },
2930
- id
2934
+ id: canUseItemId ? id : void 0
2931
2935
  });
2932
2936
  break;
2933
2937
  }
@@ -2959,6 +2963,7 @@ async function convertToOpenAIResponsesInput({
2959
2963
  break;
2960
2964
  }
2961
2965
  case "reasoning": {
2966
+ hasPrecedingReasoning = true;
2962
2967
  const providerOptions2 = await parseProviderOptions7({
2963
2968
  provider: "openai",
2964
2969
  providerOptions: part.providerOptions,
@@ -4091,6 +4096,7 @@ var OpenAIResponsesLanguageModel = class {
4091
4096
  explicitMessageItemType: this.config.explicitMessageItemType,
4092
4097
  fileIdPrefixes: this.config.fileIdPrefixes,
4093
4098
  store: (_b = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _b : true,
4099
+ isReasoningModel: modelCapabilities.isReasoningModel,
4094
4100
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4095
4101
  webSearchToolName
4096
4102
  });