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