fix: prune missing task sessions#6
Conversation
|
Note: a continuation alone may not be enough here. Agents can be constrained by event-driven background-task handling: they may wait for completion events rather than polling running tasks. If a child task dies or disappears, that event may never arrive, and since continuation prompt itself is untouched in this change, main agent may still think it can wait for task-status to come back and stops, which would trigger continuation again until turn threshold is reached. A potential fix to this would be add information of dead tasks in the continuation prompt, however I'm not sure if this is desirable. |
|
Thanks, this is a useful fix direction and the local gates pass. I found one blocker before merge: the stale-task pruning only handles a known child that is still returned by Could you also handle tracked running child task IDs that are absent from the live children list, and add a regression test for:
Optional: if |
|
Thanks for the detailed review! Updated and pushed the fix:
|
Summary
debug_logoption, which is disabled by defaultWhy
Goal continuation defers while child tasks are active so the parent session does not continue before background agents finish. That is correct while a child task is visibly running, but it can deadlock when OpenCode can no longer observe that child session.
A child task can disappear from status after an interrupt, terminating/restarting OpenCode, moving the session to a different folder, or other session-lifecycle edge cases. In that state the plugin only remembers an old
runningtask record, while live status returns missing/null. Since there is no terminal event to reconcile, the old task can block continuation forever.I hit this during development: a background agent hung, I restarted OpenCode, then asked for goal continuation. The plugin did not recognize that the task had already completed or was gone, so continuation stayed blocked by the stale child task.
This change treats missing live status as unknown/unobservable: wait a short grace period, then prune the stale task record without requiring parent reconciliation.
Manual test
Validation
bun run typecheckbun testbun run lintbun run build