@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.
@@ -2679,6 +2679,7 @@ async function convertToOpenAIResponsesInput({
2679
2679
  explicitMessageItemType = false,
2680
2680
  fileIdPrefixes,
2681
2681
  store,
2682
+ isReasoningModel = false,
2682
2683
  configurationUpdateUnsupportedReason,
2683
2684
  hasLocalShellTool = false,
2684
2685
  webSearchToolName
@@ -2832,12 +2833,14 @@ async function convertToOpenAIResponsesInput({
2832
2833
  case "assistant": {
2833
2834
  const reasoningMessages = {};
2834
2835
  const toolCallParts = {};
2836
+ let hasPrecedingReasoning = false;
2835
2837
  for (const part of content) {
2836
2838
  switch (part.type) {
2837
2839
  case "text": {
2838
2840
  const id = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.itemId;
2839
2841
  const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
2840
- if (store && id != null) {
2842
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2843
+ if (store && canUseItemId) {
2841
2844
  input.push({ type: "item_reference", id });
2842
2845
  break;
2843
2846
  }
@@ -2845,7 +2848,7 @@ async function convertToOpenAIResponsesInput({
2845
2848
  ...explicitMessageItemType && { type: "message" },
2846
2849
  role: "assistant",
2847
2850
  content: [{ type: "output_text", text: part.text }],
2848
- id,
2851
+ id: canUseItemId ? id : void 0,
2849
2852
  ...phase != null && { phase }
2850
2853
  });
2851
2854
  break;
@@ -2857,7 +2860,8 @@ async function convertToOpenAIResponsesInput({
2857
2860
  }
2858
2861
  const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
2859
2862
  const isAsync = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.async;
2860
- if (store && id != null) {
2863
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2864
+ if (store && canUseItemId) {
2861
2865
  input.push({ type: "item_reference", id });
2862
2866
  break;
2863
2867
  }
@@ -2887,7 +2891,7 @@ async function convertToOpenAIResponsesInput({
2887
2891
  name: part.toolName,
2888
2892
  arguments: JSON.stringify(part.input),
2889
2893
  ...isAsync != null && { async: isAsync },
2890
- id
2894
+ id: canUseItemId ? id : void 0
2891
2895
  });
2892
2896
  break;
2893
2897
  }
@@ -2919,6 +2923,7 @@ async function convertToOpenAIResponsesInput({
2919
2923
  break;
2920
2924
  }
2921
2925
  case "reasoning": {
2926
+ hasPrecedingReasoning = true;
2922
2927
  const providerOptions2 = await (0, import_provider_utils23.parseProviderOptions)({
2923
2928
  provider: "openai",
2924
2929
  providerOptions: part.providerOptions,
@@ -4030,6 +4035,7 @@ var OpenAIResponsesLanguageModel = class {
4030
4035
  explicitMessageItemType: this.config.explicitMessageItemType,
4031
4036
  fileIdPrefixes: this.config.fileIdPrefixes,
4032
4037
  store: (_b = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _b : true,
4038
+ isReasoningModel: modelCapabilities.isReasoningModel,
4033
4039
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4034
4040
  webSearchToolName
4035
4041
  });