fix(background-agent): use correct OpenCode session status for stale guard

OpenCode uses 'busy'/'retry'/'idle' session statuses, not 'running'.
The stale timeout guard checked for type === 'running' which never
matched, leaving all background tasks vulnerable to stale-kill even
when their sessions were actively processing.

Change sessionIsRunning to check type !== 'idle' instead, protecting
busy and retrying sessions from premature termination.
This commit is contained in:
YeonGyu-Kim
2026-02-15 14:24:45 +09:00
parent f3672c527e
commit 469e20639c
3 changed files with 120 additions and 4 deletions
+2 -1
View File
@@ -1452,7 +1452,8 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
const sessionID = task.sessionID
if (!startedAt || !sessionID) continue
const sessionIsRunning = allStatuses[sessionID]?.type === "running"
const sessionStatus = allStatuses[sessionID]?.type
const sessionIsRunning = sessionStatus !== undefined && sessionStatus !== "idle"
const runtime = now - startedAt.getTime()
if (!task.progress?.lastUpdate) {