From 2b5244a6d84f40470c63d1f5ac45854f8cdeb9e3 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 4 Feb 2026 13:14:18 +0900 Subject: [PATCH] fix(background-agent): abort session on model suggestion retry failure When promptWithModelSuggestionRetry() fails, the session was not being aborted, causing the polling loop to wait forever for an idle state. Added session.abort() calls in startTask() and resume() catch blocks. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/features/background-agent/manager.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index 7a0b30a76..768b33383 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -351,6 +351,11 @@ export class BackgroundManager { existingTask.concurrencyKey = undefined } + // Abort the session to prevent infinite polling hang + this.client.session.abort({ + path: { id: sessionID }, + }).catch(() => {}) + this.markForNotification(existingTask) this.notifyParentSession(existingTask).catch(err => { log("[background-agent] Failed to notify on error:", err) @@ -600,6 +605,14 @@ export class BackgroundManager { this.concurrencyManager.release(existingTask.concurrencyKey) existingTask.concurrencyKey = undefined } + + // Abort the session to prevent infinite polling hang + if (existingTask.sessionID) { + this.client.session.abort({ + path: { id: existingTask.sessionID }, + }).catch(() => {}) + } + this.markForNotification(existingTask) this.notifyParentSession(existingTask).catch(err => { log("[background-agent] Failed to notify on resume error:", err)