Fix: Avoid tool confirmation timeout when no UI listeners are present (#17955)

This commit is contained in:
薄明色の忘れ路
2026-02-20 02:28:06 +09:00
committed by GitHub
parent 082f41f54d
commit 5d235952ba

View File

@@ -79,8 +79,21 @@ export class MessageBus extends EventEmitter {
});
break;
case PolicyDecision.ASK_USER:
// Pass through to UI for user confirmation
this.emitMessage(message);
// Pass through to UI for user confirmation if any listeners exist.
// If no listeners are registered (e.g., headless/ACP flows),
// immediately request user confirmation to avoid long timeouts.
if (
this.listenerCount(MessageBusType.TOOL_CONFIRMATION_REQUEST) > 0
) {
this.emitMessage(message);
} else {
this.emitMessage({
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
correlationId: message.correlationId,
confirmed: false,
requiresUserConfirmation: true,
});
}
break;
default:
throw new Error(`Unknown policy decision: ${decision}`);