From 8457e8c67ef5975e4280a21acae8e2773ebdef06 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Mon, 5 Jan 2026 09:39:37 -0800 Subject: [PATCH] fix: include all approval results when auto-handling remaining approvals (#470) Co-authored-by: Letta --- src/cli/App.tsx | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/cli/App.tsx b/src/cli/App.tsx index d0adb4e..899dcff 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -4789,11 +4789,18 @@ DO NOT respond to these messages or otherwise consider them in your response unl setIsExecutingTool(true); - // Build ALL decisions: current + auto-allowed remaining - const allDecisions: Array<{ - type: "approve"; - approval: ApprovalRequest; - }> = [ + // Snapshot current state BEFORE clearing (critical for ID matching!) + // This must include ALL previous decisions, auto-handled, and auto-denied + const approvalResultsSnapshot = [...approvalResults]; + const autoHandledSnapshot = [...autoHandledResults]; + const autoDeniedSnapshot = [...autoDeniedApprovals]; + + // Build ALL decisions: previous + current + auto-allowed remaining + const allDecisions: Array< + | { type: "approve"; approval: ApprovalRequest } + | { type: "deny"; approval: ApprovalRequest; reason: string } + > = [ + ...approvalResultsSnapshot, // Include decisions from previous rounds { type: "approve", approval: currentApproval }, ...nowAutoAllowed.map((r) => ({ type: "approve" as const, @@ -4824,6 +4831,25 @@ DO NOT respond to these messages or otherwise consider them in your response unl }, ); + // Combine with auto-handled and auto-denied results (from initial check) + const allResults = [ + ...autoHandledSnapshot.map((ar) => ({ + type: "tool" as const, + tool_call_id: ar.toolCallId, + tool_return: ar.result.toolReturn, + status: ar.result.status, + stdout: ar.result.stdout, + stderr: ar.result.stderr, + })), + ...autoDeniedSnapshot.map((ad) => ({ + type: "approval" as const, + tool_call_id: ad.approval.toolCallId, + approve: false, + reason: ad.reason, + })), + ...executedResults, + ]; + setThinkingMessage(getRandomThinkingVerb()); refreshDerived(); @@ -4831,7 +4857,7 @@ DO NOT respond to these messages or otherwise consider them in your response unl await processConversation([ { type: "approval", - approvals: executedResults as ApprovalResult[], + approvals: allResults as ApprovalResult[], }, ]); } finally { @@ -4848,6 +4874,8 @@ DO NOT respond to these messages or otherwise consider them in your response unl approvalResults, approvalContexts, pendingApprovals, + autoHandledResults, + autoDeniedApprovals, handleApproveCurrent, processConversation, refreshDerived,