@zenning/openai 3.0.12 → 3.0.13

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,11 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix duplicate item_reference for approval responses. Skip creating item_reference for all tool-calls when approval responses are detected in the prompt, preventing duplicate item errors with previousResponseId.
8
+
3
9
  ## 3.0.12
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2484,44 +2484,10 @@ async function convertToOpenAIResponsesInput({
2484
2484
  const input = [];
2485
2485
  const warnings = [];
2486
2486
  const processedApprovalIds = /* @__PURE__ */ new Set();
2487
- const approvalIdToToolCallId = /* @__PURE__ */ new Map();
2488
- for (const message of prompt) {
2489
- if (message.role === "assistant") {
2490
- console.log("[OpenAI Provider] Assistant message content type:", typeof message.content, "isArray:", Array.isArray(message.content));
2491
- if (Array.isArray(message.content)) {
2492
- console.log("[OpenAI Provider] Assistant content parts:", message.content.map((p) => p.type));
2493
- const approvalRequests = message.content.filter(
2494
- (p) => p.type === "tool-approval-request"
2495
- );
2496
- console.log("[OpenAI Provider] Found approval requests:", approvalRequests.length);
2497
- for (const req of approvalRequests) {
2498
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2499
- }
2500
- }
2501
- }
2502
- }
2503
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2504
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2505
- for (const message of prompt) {
2506
- if (message.role === "tool") {
2507
- for (const part of message.content) {
2508
- if (part.type === "tool-approval-response") {
2509
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2510
- console.log("[OpenAI Provider] Found approval response:", {
2511
- approvalId: part.approvalId,
2512
- toolCallId
2513
- });
2514
- if (toolCallId) {
2515
- toolCallsWithApprovalResponses.add(toolCallId);
2516
- }
2517
- }
2518
- }
2519
- }
2520
- }
2521
- console.log(
2522
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2523
- toolCallsWithApprovalResponses
2487
+ const hasApprovalResponses = prompt.some(
2488
+ (message) => message.role === "tool" && message.content.some((part) => part.type === "tool-approval-response")
2524
2489
  );
2490
+ console.log("[OpenAI Provider] Approval continuation detected:", hasApprovalResponses);
2525
2491
  if (compactionInput && compactionInput.length > 0) {
2526
2492
  input.push(...compactionInput);
2527
2493
  }
@@ -2599,14 +2565,6 @@ async function convertToOpenAIResponsesInput({
2599
2565
  }
2600
2566
  case "assistant": {
2601
2567
  const reasoningMessages = {};
2602
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2603
- if (Array.isArray(content)) {
2604
- for (const part of content) {
2605
- if (part.type === "tool-approval-request") {
2606
- toolCallsWithApprovalRequest.add(part.toolCallId);
2607
- }
2608
- }
2609
- }
2610
2568
  for (const part of content) {
2611
2569
  switch (part.type) {
2612
2570
  case "text": {
@@ -2624,21 +2582,14 @@ async function convertToOpenAIResponsesInput({
2624
2582
  }
2625
2583
  case "tool-call": {
2626
2584
  const id = (_g = (_d = (_c = part.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.itemId) != null ? _g : (_f = (_e = part.providerMetadata) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.itemId;
2627
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2628
- part.toolCallId
2629
- );
2630
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2631
- part.toolCallId
2632
- );
2633
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2585
+ const skipItemReference = hasApprovalResponses;
2634
2586
  console.log("[OpenAI Provider] Processing tool-call:", {
2635
2587
  toolCallId: part.toolCallId,
2636
2588
  toolName: part.toolName,
2637
2589
  id,
2638
2590
  providerExecuted: part.providerExecuted,
2639
2591
  store,
2640
- hasApprovalResponse,
2641
- hasApprovalRequest,
2592
+ hasApprovalResponses,
2642
2593
  skipItemReference,
2643
2594
  willCreateItemReference: store && id != null && !skipItemReference
2644
2595
  });
@@ -5837,7 +5788,7 @@ var OpenAITranscriptionModel = class {
5837
5788
  };
5838
5789
 
5839
5790
  // src/version.ts
5840
- var VERSION = true ? "3.0.11" : "0.0.0-test";
5791
+ var VERSION = true ? "3.0.12" : "0.0.0-test";
5841
5792
 
5842
5793
  // src/openai-provider.ts
5843
5794
  function createOpenAI(options = {}) {