Repository navigation
Description
Prerequisites
- I will write this issue in English (see the Language Policy)
- I have searched existing issues to avoid duplicates
- I am using the latest version of oh-my-openagent
- I have read the documentation or asked an AI coding agent with this project's GitHub URL loaded and couldn't find the answer
Bug Description
When background tasks complete, oh-my-openagent injects a final system reminder into the parent session:
<system-reminder>
[BACKGROUND TASK COMPLETED]
[ALL BACKGROUND TASKS COMPLETE]
**Completed:**
- `bg_xxx`: ...
- `bg_yyy`: ...
Use `background_output(task_id="<id>")` to retrieve each result.
</system-reminder>
<!-- OMO_INTERNAL_INITIATOR -->This final notification should wake the parent assistant so it can call background_output(...) and continue the workflow.
Instead, the notification appears in the session, but the assistant does not continue until a real user message is sent manually.
Steps to Reproduce
-
Start a parent OpenCode session with oh-my-openagent enabled.
-
Launch two background tasks from the assistant.
-
End the assistant turn and wait for background completion.
-
Runtime injects the final completion reminder:
<system-reminder> [BACKGROUND TASK COMPLETED] [ALL BACKGROUND TASKS COMPLETE] ... </system-reminder> <!-- OMO_INTERNAL_INITIATOR -->
-
Observe that the parent assistant does not respond automatically.
-
Send any real user message.
-
The assistant is then awakened and can retrieve background outputs.
Expected Behavior
After [ALL BACKGROUND TASKS COMPLETE] is injected, the parent assistant should automatically receive a turn and continue, typically by calling:
background_output(task_id="bg_xxx")
background_output(task_id="bg_yyy")The background-agent workflow should not require the user to send another message after the final system reminder.
Actual Behavior
The final background completion system reminder is written into the session, but no assistant turn follows.
In reproduced sessions, the message history ended with:
<system-reminder>
[BACKGROUND TASK COMPLETED]
[ALL BACKGROUND TASKS COMPLETE]
...
</system-reminder>
<!-- OMO_INTERNAL_INITIATOR -->There was no assistant response after this runtime-injected message. The assistant only continued after a real user message was sent.
Evidence from reproduced sessions:
- The messages were stored as
role: "user". - They included
<system-reminder>...</system-reminder>. - They included
<!-- OMO_INTERNAL_INITIATOR -->. - The task IDs matched real background task IDs.
- No assistant message appeared after the final all-complete notification.
The same behavior was reproduced in an active session: background tasks completed, the final [ALL BACKGROUND TASKS COMPLETE] notification appeared, but the assistant did not automatically continue until the user sent another message.
Doctor Output
Resolving dependencies
Resolved, downloaded and extracted [341]
Saved lockfile
Doctor failed unexpectedly: ResolveMessage: Cannot find module 'oh-my-opencode/package.json' from '/private/var/folders/r5/xdvc0dcn4vq2dzqg08hst7q80000gn/T/bunx-501-oh-my-openagent@latest/node_modules/oh-my-openagent/dist/cli/index.js'
This may indicate memory pressure (OOM/SIGKILL) or a corrupted installation.
Try: OMO_DISABLE_POSTHOG=1 bunx oh-my-opencode doctor --verboseError Logs
No thrown runtime error was shown in the UI. The observable failure is that the parent assistant is not awakened after the final completion reminder.
Relevant suspected flow:
background task completes
→ notifyParentSession()
→ queuePendingParentWake()
→ flushPendingParentWake()
→ sendParentWakePrompt()
→ dispatchInternalPrompt()
→ dispatchAfterSessionIdle()
→ promptAsync()
→ assistant should reply, but does not
For final completion notifications, the code appears to set:
shouldReply = allComplete || isTaskFailureSo [ALL BACKGROUND TASKS COMPLETE] should require a reply.
However, before dispatching the parent wake, dispatchAfterSessionIdle() checks whether the latest assistant turn blocks internal prompts, via logic equivalent to:
latestAssistantTurnBlocksInternalPrompt(messages)The problematic logic appears to be:
if (role === "user") {
if (messageIsSyntheticOrInternalUser(message)) {
if (!sawAssistantAfterLatestUser) {
return true;
}
continue;
}
return false;
}The final completion notification is itself an internal/synthetic user message because it contains:
<!-- OMO_INTERNAL_INITIATOR -->So after the final notification is injected:
- The latest message is a synthetic/internal user message.
- There is no assistant message after it yet.
latestAssistantTurnBlocksInternalPrompt()returnstrue.dispatchAfterSessionIdle()treats the session as blocked/active.- The parent wake does not produce an assistant reply.
- The assistant never calls
background_output(...).
This looks like a self-blocking loop: the completion notification that should wake the assistant becomes the reason the wake is blocked.
Configuration
{}No special per-project oh-my-openagent configuration is required to reproduce this. The issue was observed with the normal background task workflow.
Additional Context
Why this appears to be a bug:
[ALL BACKGROUND TASKS COMPLETE] is an actionable runtime notification. It should not be treated the same way as an arbitrary internal user message that blocks additional internal prompts.
The notification explicitly tells the assistant what to do:
Use background_output(task_id="<id>") to retrieve each result.
But the assistant never gets a turn to do it.
Possible fixes:
Option A: Special-case final background completion reminders
If the latest synthetic/internal user message is a final background completion notification, do not let it block parent wake dispatch.
For example, detect headers like:
[ALL BACKGROUND TASKS COMPLETE]
[ALL BACKGROUND TASKS FINISHED - N FAILED]
and allow the wake.
Option B: Bypass latestAssistantTurnBlocksInternalPrompt() for shouldReply=true parent wakes
If a parent wake has shouldReply=true, especially for final completion or failure notifications, avoid treating the just-injected internal reminder as a blocker.
Option C: Dispatch the wake before writing the notification as a blocking internal user message
Avoid a state where the notification becomes the latest synthetic user message before the wake prompt is dispatched.
Suggested regression test:
[user] original request
[assistant] launches background tasks and stops
[user/internal] <system-reminder>[BACKGROUND TASK COMPLETED][ALL BACKGROUND TASKS COMPLETE]...</system-reminder><!-- OMO_INTERNAL_INITIATOR -->
Expected result:
assistant turn is dispatched
assistant can call background_output(...)
This currently breaks the documented background-agent workflow:
- Agents are told to stop and wait for
<system-reminder>. - Runtime injects the reminder.
- But the assistant is not woken up to collect results.
As a result, workflows depending on background agents stall until the user manually sends another message.
Operating System
macOS
OpenCode Version
1.17.2
Activity
[-]Background task completion reminder does not wake parent assistant[/-][+][Bug]: Background task completion reminder does not wake parent assistant[/+]vboufleur commentedon Jun 10, 2026
Great analysis here. I also investigated this bug and can confirm your findings.
latestAssistantTurnBlocksInternalPrompt()indeed blocks the wake dispatch by treating the synthetic notification message as a blocker.The Permanent Deadlock Path
My investigation tracked the complete state machine through the flush runner, showing this is a permanent infinite loop rather than a temporary block:
noReply: true) when there's recent activity, creating the synthetic user message but no assistant response.message.updatedevent, callingrecordParentSessionActivity()atmanager.ts:1584. Since this function doesn't filter out internal messages, it refreshes the 5-second activity window. This traps subsequent flushes in the "recent activity" path.noReplyAdmittedAtis set, later flushes detectingshouldReply && noReplyAdmittedAt !== undefinedconstantly reschedule themselves without dispatching.latestAssistantTurnHasToolBlock(messages)isfalseonce the agent finishes normally.{ defer: true }, causingdeferReplyWakeWhileUnsafeto reschedule forever. The wake never dispatches withnoReply: false.Proposed Escape Hatch Fix
Instead of the proposed options in the issue, I added a targeted escape hatch inside
getParentWakeSessionHistoryDeferralDecisioninparent-wake-session-history.ts:This is safer and more precise than the alternatives:
noReplyAdmittedAt, isolating the exact deadlock scenario (safer than Option B).Testing
I implemented this fix and added three regression tests covering:
noReplyAdmittedAtto ensure it still defers.Verified
To confirm the fix in a production-like environment, I built the package locally and pointed OpenCode's configuration to this build. During a live session, the main agent successfully launched background agents and resumed right after they completed. This verified that the deadlock is fully resolved under real-world conditions.
I'm opening a PR with the changes.
vboufleur commentedon Jun 10, 2026
Here's the PR: #5148
@code-yeongyu Ping
zsj0613 commentedon Jun 11, 2026
this is very Annoying, please fix it quick
airnayden commentedon Jun 11, 2026
Can confirm the issue as well.
cpt-sd76vg commentedon Jun 11, 2026
I’m really hoping PR #5148 gets merged soon....
At the moment, Sisyphus gets stuck without picking up the results from parallel agents, which makes it very hard to use in practice.
vboufleur commentedon Jun 11, 2026
While we wait for #5148 to be merged, you can apply the fix locally by pointing OpenCode at my fork's branch. This is what I did on my machine and it fully resolves the deadlock.
1. Clone the fork and check out the fix branch:
git clone https://github.com/vboufleur/oh-my-openagent.git /tmp/omo-fix cd /tmp/omo-fix git checkout fix/parent-wake-noreply-admission-deadlock2. Install deps and build:
This produces
dist/index.jsat the repo root.3. Point OpenCode at the local build. Edit
~/.config/opencode/opencode.jsonand replace the published plugin entry with afile://path to the cloned repo:(Keep any other plugins you already have in that array.)
4. Restart OpenCode.
Verify: Start a session, have the assistant launch 2 background agents, then end the turn and wait. Once the tasks complete and the
[ALL BACKGROUND TASKS COMPLETE]reminder appears, the assistant should automatically resume (~10s later) and callbackground_output(...)on its own — no manual user message needed.If you'd rather not build from source, you can also wait for #5148 this is just a stopgap to unblock the background-agent workflow in the meantime.
Note: I used
/tmp/omo-fixas an example path — adjust to wherever you cloned it, and make sure thefile://path in the config matches. The fix is a targeted escape hatch inparent-wake-session-history.ts(plus 3 regression tests), so the build is the standard package build with no extra steps.cpt-sd76vg commentedon Jun 11, 2026
@vboufleur
Thanks for sharing the workaround. I was able to get it working with a couple of additional steps in my environment.
In addition to the steps you described, I temporarily disabled only this entry in
tui.jsonc:I left my other plugin entries unchanged.
Also, some of the LSP-related tools were not working at first, so I changed the build steps to:
With those steps, everything started working properly.
I briefly tested it with Sisyphus, and for the first time in a while it actually picked up the sub-agent results and continued correctly. Thank you so much for the fix and the clear instructions!
Also, I know @code-yeongyu must be very busy, but I’m looking forward to the official optimization/merge when possible.
fix(background-agent): look through noReply tails in prompt gate to p…
acamq commentedon Jun 11, 2026
Hello everyone! Thank you for your patience, fix has been merged and will be in the next release.