From f853d2f9dab60083b53f1000240e7da0992321d6 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Tue, 24 Mar 2026 12:28:18 -0700 Subject: [PATCH] fix: explicitly fail pending tool calls when approval is required This commit ensures that when a tool call enters the 'awaiting_approval' state (which is not yet supported in the new protocol), we not only emit a fatal error but also emit a 'tool_response' event with 'isError: true'. This allows the UI to correctly transition the tool call from a pending (scheduled/executing) state to an error state, providing clear visual feedback to the user and preventing the UI from appearing to hang. --- packages/core/src/agent/legacy-agent-session.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/core/src/agent/legacy-agent-session.ts b/packages/core/src/agent/legacy-agent-session.ts index 6286305634..58063f200a 100644 --- a/packages/core/src/agent/legacy-agent-session.ts +++ b/packages/core/src/agent/legacy-agent-session.ts @@ -170,6 +170,15 @@ class LegacyAgentProtocol implements AgentProtocol { for (const tc of event.toolCalls) { if (tc.status === 'awaiting_approval') { this._emit([ + this._makeToolResponseEvent({ + requestId: tc.request.callId, + name: tc.request.name, + content: [ + { type: 'text', text: 'Tool approvals not yet implemented.' }, + ], + isError: true, + displayContent: [{ type: 'text', text: 'Approval required' }], + }), this._makeErrorEvent({ status: 'UNIMPLEMENTED', message: