Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): handle empty responses from the chat service

Steven Enamakele9e7b005716d
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index 93016eb1e0..c01d5d2675 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -1683,11 +1683,14 @@ export interface ChatCancelOutcome {
* callers.
*/
export async function chatCancel(threadId: string, requestId?: string): Promise<ChatCancelOutcome> {
- const socket = socketService.getSocket();
- const clientId = socket?.id;
- if (!clientId) {
- chatLog('chat_cancel: no socket id thread=%s — cancel not sent', threadId);
- return { accepted: false, turnCancelled: false };
+ // The cancel itself is an HTTP RPC; the client id only routes the
+ // `chat_cancelled` event that follows (which also goes to the thread room).
+ // A socket that is down or mid-reconnect — exactly when a turn is most
+ // likely to look stuck — must not swallow the Stop, so fall back to a
+ // placeholder id rather than refusing to send.
+ const clientId = socketService.getSocket()?.id || NO_SOCKET_CANCEL_CLIENT_ID;
+ if (clientId === NO_SOCKET_CANCEL_CLIENT_ID) {
+ chatLog('chat_cancel: no socket id thread=%s — sending cancel without one', threadId);
}
try {