From 80cfe87390f5e9cdeedce93898f0216aefca9e62 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 11 Dec 2025 17:23:40 +0900 Subject: [PATCH] fix(background-agent): use promptAsync to wake parent session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change prompt() to promptAsync() for parent session notification - Only mark 404 errors as permanent task failure - Add defensive progress initialization 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/features/background-agent/manager.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index 25c9ee3..585157f 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -237,7 +237,7 @@ export class BackgroundManager { Use \`background_result\` tool with taskId="${task.id}" to retrieve the full result.` - this.client.session.prompt({ + this.client.session.promptAsync({ path: { id: task.parentSessionID }, body: { parts: [{ type: "text", text: message }], @@ -278,10 +278,13 @@ Use \`background_result\` tool with taskId="${task.id}" to retrieve the full res }) if (infoResult.error) { - task.status = "error" - task.error = "Session not found" - task.completedAt = new Date() - this.persist() + const errorStr = String(infoResult.error) + if (errorStr.includes("404") || errorStr.includes("not found")) { + task.status = "error" + task.error = "Session not found" + task.completedAt = new Date() + this.persist() + } continue } @@ -322,11 +325,12 @@ Use \`background_result\` tool with taskId="${task.id}" to retrieve the full res } } - if (task.progress) { - task.progress.toolCalls = toolCalls - task.progress.lastTool = lastTool - task.progress.lastUpdate = new Date() + if (!task.progress) { + task.progress = { toolCalls: 0, lastUpdate: new Date() } } + task.progress.toolCalls = toolCalls + task.progress.lastTool = lastTool + task.progress.lastUpdate = new Date() } } catch { void 0