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:
parent
a37259326a
commit
5b34a98e0a
@ -343,7 +343,7 @@ export class BackgroundManager {
|
|||||||
log("[background-agent] promptAsync error:", error)
|
log("[background-agent] promptAsync error:", error)
|
||||||
const existingTask = this.findBySession(sessionID)
|
const existingTask = this.findBySession(sessionID)
|
||||||
if (existingTask) {
|
if (existingTask) {
|
||||||
existingTask.status = "error"
|
existingTask.status = "interrupt"
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
|
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.`
|
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) => {
|
}).catch((error) => {
|
||||||
log("[background-agent] resume prompt error:", error)
|
log("[background-agent] resume prompt error:", error)
|
||||||
existingTask.status = "error"
|
existingTask.status = "interrupt"
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
existingTask.error = errorMessage
|
existingTask.error = errorMessage
|
||||||
existingTask.completedAt = new Date()
|
existingTask.completedAt = new Date()
|
||||||
@ -1132,7 +1132,7 @@ export class BackgroundManager {
|
|||||||
allComplete = true
|
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}` : ""
|
const errorInfo = task.error ? `\n**Error:** ${task.error}` : ""
|
||||||
|
|
||||||
let notification: string
|
let notification: string
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export async function resumeBackgroundTask(args: {
|
|||||||
},
|
},
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
log("[background-agent] resume prompt error:", error)
|
log("[background-agent] resume prompt error:", error)
|
||||||
existingTask.status = "error"
|
existingTask.status = "interrupt"
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
existingTask.error = errorMessage
|
existingTask.error = errorMessage
|
||||||
existingTask.completedAt = new Date()
|
existingTask.completedAt = new Date()
|
||||||
|
|||||||
@ -164,7 +164,7 @@ export async function startQueuedTask(args: {
|
|||||||
const existingTask = findBySession(sessionID)
|
const existingTask = findBySession(sessionID)
|
||||||
if (!existingTask) return
|
if (!existingTask) return
|
||||||
|
|
||||||
existingTask.status = "error"
|
existingTask.status = "interrupt"
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
|
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.`
|
existingTask.error = `Agent "${input.agent}" not found. Make sure the agent is registered in your opencode.json or provided by a plugin.`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user