forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Bug
When an async task completes, the parent session is NOT automatically woken up to deliver the result. The PM only discovers task completion when explicitly polling via check_task or list_tasks.
Observed Behavior
- PM dispatches task (async mode)
- Subagent completes in ~7s
- PM sits idle for 50+ seconds with no notification
- User asks 'did the agent finish?'
- PM calls
check_taskand discovers it completed
Expected Behavior
When subagent completes, parent session should receive an automatic notification injecting [System: Background tasks completed] into context, triggering the PM to respond.
Root Cause Analysis
enableAutoWakeup() in async-tasks.ts subscribes to BackgroundTaskEvent.Completed on the Bus. When the event fires, triggerWakeup() calls SessionPrompt.prompt() with empty parts — relying on getAndClearCompletedTasks() to inject the completed task notification.
Suspected causes:
wakeupInProgressguard blocking re-entry if parent session was still processinghasUndeliveredCompletedTasks(sessionID)filtering by wrong sessionID (child vs parent)- Race condition: task completes before
enableAutoWakeupsubscription is fully registered - Bus pub/sub not crossing ACP session boundary correctly
Key Code
src/session/async-tasks.ts—enableAutoWakeup(),triggerWakeup()src/tool/task.ts— callsenableAutoWakeup(ctx.sessionID)before spawning task- Bus event published with
parentSessionID = ctx.sessionID - Handler filters:
event.properties.parentSessionID !== sessionID
Quality Gates
- Reproduce with test
- Fix root cause
- Verify auto-notification fires reliably
- No regression in sync mode
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels