@zenning/openai 3.0.11 → 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.
@@ -2496,39 +2496,10 @@ async function convertToOpenAIResponsesInput({
2496
2496
  const input = [];
2497
2497
  const warnings = [];
2498
2498
  const processedApprovalIds = /* @__PURE__ */ new Set();
2499
- const approvalIdToToolCallId = /* @__PURE__ */ new Map();
2500
- for (const message of prompt) {
2501
- if (message.role === "assistant" && Array.isArray(message.content)) {
2502
- const approvalRequests = message.content.filter(
2503
- (p) => p.type === "tool-approval-request"
2504
- );
2505
- for (const req of approvalRequests) {
2506
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2507
- }
2508
- }
2509
- }
2510
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2511
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2512
- for (const message of prompt) {
2513
- if (message.role === "tool") {
2514
- for (const part of message.content) {
2515
- if (part.type === "tool-approval-response") {
2516
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2517
- console.log("[OpenAI Provider] Found approval response:", {
2518
- approvalId: part.approvalId,
2519
- toolCallId
2520
- });
2521
- if (toolCallId) {
2522
- toolCallsWithApprovalResponses.add(toolCallId);
2523
- }
2524
- }
2525
- }
2526
- }
2527
- }
2528
- console.log(
2529
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2530
- toolCallsWithApprovalResponses
2499
+ const hasApprovalResponses = prompt.some(
2500
+ (message) => message.role === "tool" && message.content.some((part) => part.type === "tool-approval-response")
2531
2501
  );
2502
+ console.log("[OpenAI Provider] Approval continuation detected:", hasApprovalResponses);
2532
2503
  if (compactionInput && compactionInput.length > 0) {
2533
2504
  input.push(...compactionInput);
2534
2505
  }
@@ -2606,14 +2577,6 @@ async function convertToOpenAIResponsesInput({
2606
2577
  }
2607
2578
  case "assistant": {
2608
2579
  const reasoningMessages = {};
2609
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2610
- if (Array.isArray(content)) {
2611
- for (const part of content) {
2612
- if (part.type === "tool-approval-request") {
2613
- toolCallsWithApprovalRequest.add(part.toolCallId);
2614
- }
2615
- }
2616
- }
2617
2580
  for (const part of content) {
2618
2581
  switch (part.type) {
2619
2582
  case "text": {
@@ -2631,21 +2594,14 @@ async function convertToOpenAIResponsesInput({
2631
2594
  }
2632
2595
  case "tool-call": {
2633
2596
  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;
2634
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2635
- part.toolCallId
2636
- );
2637
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2638
- part.toolCallId
2639
- );
2640
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2597
+ const skipItemReference = hasApprovalResponses;
2641
2598
  console.log("[OpenAI Provider] Processing tool-call:", {
2642
2599
  toolCallId: part.toolCallId,
2643
2600
  toolName: part.toolName,
2644
2601
  id,
2645
2602
  providerExecuted: part.providerExecuted,
2646
2603
  store,
2647
- hasApprovalResponse,
2648
- hasApprovalRequest,
2604
+ hasApprovalResponses,
2649
2605
  skipItemReference,
2650
2606
  willCreateItemReference: store && id != null && !skipItemReference
2651
2607
  });