fix(background-agent): use promptAsync to wake parent session
- 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)
This commit is contained in:
@@ -237,7 +237,7 @@ export class BackgroundManager {
|
|||||||
|
|
||||||
Use \`background_result\` tool with taskId="${task.id}" to retrieve the full result.`
|
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 },
|
path: { id: task.parentSessionID },
|
||||||
body: {
|
body: {
|
||||||
parts: [{ type: "text", text: message }],
|
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) {
|
if (infoResult.error) {
|
||||||
|
const errorStr = String(infoResult.error)
|
||||||
|
if (errorStr.includes("404") || errorStr.includes("not found")) {
|
||||||
task.status = "error"
|
task.status = "error"
|
||||||
task.error = "Session not found"
|
task.error = "Session not found"
|
||||||
task.completedAt = new Date()
|
task.completedAt = new Date()
|
||||||
this.persist()
|
this.persist()
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,12 +325,13 @@ Use \`background_result\` tool with taskId="${task.id}" to retrieve the full res
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task.progress) {
|
if (!task.progress) {
|
||||||
|
task.progress = { toolCalls: 0, lastUpdate: new Date() }
|
||||||
|
}
|
||||||
task.progress.toolCalls = toolCalls
|
task.progress.toolCalls = toolCalls
|
||||||
task.progress.lastTool = lastTool
|
task.progress.lastTool = lastTool
|
||||||
task.progress.lastUpdate = new Date()
|
task.progress.lastUpdate = new Date()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
void 0
|
void 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user