feat(background-agent): use "interrupt" status for promptAsync errors

Change promptAsync catch blocks to set status = "interrupt" instead of "error".

This distinguishes prompt errors from stale timeouts (cancelled) and TTL expirations (error).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-02-09 18:25:54 +09:00
parent a37259326a
commit 5b34a98e0a
3 changed files with 5 additions and 5 deletions

View File

@@ -343,7 +343,7 @@ export class BackgroundManager {
log("[background-agent] promptAsync error:", error)
const existingTask = this.findBySession(sessionID)
if (existingTask) {
existingTask.status = "error"
existingTask.status = "interrupt"
const errorMessage = error instanceof Error ? error.message : String(error)
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
existingTask.error = `Agent "${input.agent}" not found. Make sure the agent is registered in your opencode.json or provided by a plugin.`
@@ -600,7 +600,7 @@ export class BackgroundManager {
},
}).catch((error) => {
log("[background-agent] resume prompt error:", error)
existingTask.status = "error"
existingTask.status = "interrupt"
const errorMessage = error instanceof Error ? error.message : String(error)
existingTask.error = errorMessage
existingTask.completedAt = new Date()
@@ -1132,7 +1132,7 @@ export class BackgroundManager {
allComplete = true
}
const statusText = task.status === "completed" ? "COMPLETED" : "CANCELLED"
const statusText = task.status === "completed" ? "COMPLETED" : task.status === "interrupt" ? "INTERRUPTED" : "CANCELLED"
const errorInfo = task.error ? `\n**Error:** ${task.error}` : ""
let notification: string

View File

@@ -121,7 +121,7 @@ export async function resumeBackgroundTask(args: {
},
}).catch((error) => {
log("[background-agent] resume prompt error:", error)
existingTask.status = "error"
existingTask.status = "interrupt"
const errorMessage = error instanceof Error ? error.message : String(error)
existingTask.error = errorMessage
existingTask.completedAt = new Date()

View File

@@ -164,7 +164,7 @@ export async function startQueuedTask(args: {
const existingTask = findBySession(sessionID)
if (!existingTask) return
existingTask.status = "error"
existingTask.status = "interrupt"
const errorMessage = error instanceof Error ? error.message : String(error)
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
existingTask.error = `Agent "${input.agent}" not found. Make sure the agent is registered in your opencode.json or provided by a plugin.`