@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.
@@ -2475,44 +2475,10 @@ async function convertToOpenAIResponsesInput({
2475
2475
  const input = [];
2476
2476
  const warnings = [];
2477
2477
  const processedApprovalIds = /* @__PURE__ */ new Set();
2478
- const approvalIdToToolCallId = /* @__PURE__ */ new Map();
2479
- for (const message of prompt) {
2480
- if (message.role === "assistant") {
2481
- console.log("[OpenAI Provider] Assistant message content type:", typeof message.content, "isArray:", Array.isArray(message.content));
2482
- if (Array.isArray(message.content)) {
2483
- console.log("[OpenAI Provider] Assistant content parts:", message.content.map((p) => p.type));
2484
- const approvalRequests = message.content.filter(
2485
- (p) => p.type === "tool-approval-request"
2486
- );
2487
- console.log("[OpenAI Provider] Found approval requests:", approvalRequests.length);
2488
- for (const req of approvalRequests) {
2489
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2490
- }
2491
- }
2492
- }
2493
- }
2494
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2495
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2496
- for (const message of prompt) {
2497
- if (message.role === "tool") {
2498
- for (const part of message.content) {
2499
- if (part.type === "tool-approval-response") {
2500
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2501
- console.log("[OpenAI Provider] Found approval response:", {
2502
- approvalId: part.approvalId,
2503
- toolCallId
2504
- });
2505
- if (toolCallId) {
2506
- toolCallsWithApprovalResponses.add(toolCallId);
2507
- }
2508
- }
2509
- }
2510
- }
2511
- }
2512
- console.log(
2513
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2514
- toolCallsWithApprovalResponses
2478
+ const hasApprovalResponses = prompt.some(
2479
+ (message) => message.role === "tool" && message.content.some((part) => part.type === "tool-approval-response")
2515
2480
  );
2481
+ console.log("[OpenAI Provider] Approval continuation detected:", hasApprovalResponses);
2516
2482
  if (compactionInput && compactionInput.length > 0) {
2517
2483
  input.push(...compactionInput);
2518
2484
  }
@@ -2590,14 +2556,6 @@ async function convertToOpenAIResponsesInput({
2590
2556
  }
2591
2557
  case "assistant": {
2592
2558
  const reasoningMessages = {};
2593
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2594
- if (Array.isArray(content)) {
2595
- for (const part of content) {
2596
- if (part.type === "tool-approval-request") {
2597
- toolCallsWithApprovalRequest.add(part.toolCallId);
2598
- }
2599
- }
2600
- }
2601
2559
  for (const part of content) {
2602
2560
  switch (part.type) {
2603
2561
  case "text": {
@@ -2615,21 +2573,14 @@ async function convertToOpenAIResponsesInput({
2615
2573
  }
2616
2574
  case "tool-call": {
2617
2575
  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;
2618
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2619
- part.toolCallId
2620
- );
2621
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2622
- part.toolCallId
2623
- );
2624
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2576
+ const skipItemReference = hasApprovalResponses;
2625
2577
  console.log("[OpenAI Provider] Processing tool-call:", {
2626
2578
  toolCallId: part.toolCallId,
2627
2579
  toolName: part.toolName,
2628
2580
  id,
2629
2581
  providerExecuted: part.providerExecuted,
2630
2582
  store,
2631
- hasApprovalResponse,
2632
- hasApprovalRequest,
2583
+ hasApprovalResponses,
2633
2584
  skipItemReference,
2634
2585
  willCreateItemReference: store && id != null && !skipItemReference
2635
2586
  });