@ai-sdk/openai 4.0.92 → 4.0.93

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,13 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.93
4
+
5
+ ### Patch Changes
6
+
7
+ - 216e2c9: fix(openai): send assistant text with content instead of an item reference when its reasoning was removed
8
+
9
+ With reasoning models and `store: true`, pruning reasoning (e.g. `pruneMessages({ reasoning: 'all' })`) caused follow-up requests to fail with "Item 'msg\_...' of type 'message' was provided without its required 'reasoning' item". Assistant text parts are now only sent as item references when they are preceded by reasoning in the same assistant message.
10
+
3
11
  ## 4.0.92
4
12
 
5
13
  ### Patch Changes
package/dist/index.js CHANGED
@@ -4766,7 +4766,7 @@ function isFileId(data, prefixes) {
4766
4766
  if (!prefixes) return false;
4767
4767
  return prefixes.some((prefix) => data.startsWith(prefix));
4768
4768
  }
4769
- async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMessageMode, providerOptionsName, explicitMessageItemType = false, fileIdPrefixes, passThroughUnsupportedFiles = false, store, hasConversation = false, hasPreviousResponseId = false, hasLocalShellTool = false, hasShellTool = false, hasApplyPatchTool = false, hasComputerTool = false, toolSearchToolName, customProviderToolNames, outputSchemaToolNames, configurationUpdateUnsupportedReason }) {
4769
+ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMessageMode, providerOptionsName, explicitMessageItemType = false, fileIdPrefixes, passThroughUnsupportedFiles = false, store, isReasoningModel = false, hasConversation = false, hasPreviousResponseId = false, hasLocalShellTool = false, hasShellTool = false, hasApplyPatchTool = false, hasComputerTool = false, toolSearchToolName, customProviderToolNames, outputSchemaToolNames, configurationUpdateUnsupportedReason }) {
4770
4770
  let input = [];
4771
4771
  const warnings = [];
4772
4772
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -4907,13 +4907,14 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
4907
4907
  case "assistant": {
4908
4908
  const reasoningMessages = {};
4909
4909
  const emittedTextItemIds = /* @__PURE__ */ new Set();
4910
+ let hasPrecedingReasoning = false;
4910
4911
  for (const part of content) switch (part.type) {
4911
4912
  case "text": {
4912
4913
  const providerOptions = part.providerOptions?.[providerOptionsName];
4913
4914
  const id = providerOptions?.itemId;
4914
4915
  const phase = providerOptions?.phase;
4915
4916
  if (hasConversation && id != null) break;
4916
- if (store && id != null) {
4917
+ if (store && id != null && (!isReasoningModel || hasPrecedingReasoning)) {
4917
4918
  if (!emittedTextItemIds.has(id)) {
4918
4919
  emittedTextItemIds.add(id);
4919
4920
  input.push({
@@ -5233,6 +5234,7 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
5233
5234
  break;
5234
5235
  }
5235
5236
  case "reasoning": {
5237
+ hasPrecedingReasoning = true;
5236
5238
  const providerOptions = await parseProviderOptions({
5237
5239
  provider: providerOptionsName,
5238
5240
  providerOptions: part.providerOptions,
@@ -6272,6 +6274,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6272
6274
  fileIdPrefixes: config.fileIdPrefixes,
6273
6275
  passThroughUnsupportedFiles: openaiOptions?.passThroughUnsupportedFiles ?? false,
6274
6276
  store: openaiOptions?.store ?? true,
6277
+ isReasoningModel,
6275
6278
  hasConversation: openaiOptions?.conversation != null,
6276
6279
  hasPreviousResponseId: openaiOptions?.previousResponseId != null,
6277
6280
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -10168,7 +10171,7 @@ var OpenAISkills = class {
10168
10171
  };
10169
10172
  //#endregion
10170
10173
  //#region src/version.ts
10171
- const VERSION = "4.0.92";
10174
+ const VERSION = "4.0.93";
10172
10175
  //#endregion
10173
10176
  //#region src/openai-provider.ts
10174
10177
  /**