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.
This commit is contained in:
Michael Bleigh
2026-03-24 12:28:18 -07:00
parent 0f37dd1d78
commit f853d2f9da
@@ -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: