Repository navigation
fix(opencode): retire a subagent's blocker when the root turn ends - #22604
Conversation
A descendant's question is stored under its own sourceSessionID but displayed on the root session it rolls up to. clearAttentionForSession matches only the source, so the root's own idle could never retire it: the blocker outlived the turn that raised it and pinned the pane on "needs input" with nothing left to answer. The lead agent truthfully reports no pending question, because the blocker belongs to a child it does not know about (#22371). Add clearAttentionForTurnEnd, matching the source id or the rolled-up root, and use it only from the idle branch. Scoped to turn end deliberately: a live blocker must still outrank the root going Busy, since a subagent can be waiting on the user while the root keeps working — widening the existing clear broke exactly that test, which is what surfaced the right scope. Shared with the OpenCode family, so mimo-code gets the same fix; both pinned plugin digests move. New test fails without the change: after the root turn ends the last post is still AskUserQuestion instead of SessionIdle.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe generated status lifecycle plugin now calls Fixed issue severity: <fixed_issue_severity>Low</fixed_issue_severity> Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A child’s question can remain displayed after the root turn ends if lineage lookup fails. Fix the fallback idle path before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Clear displayed-root attention when lineage lookup fails. · status-plugin-lifecycle-source.ts:56
src/main/opencode/status-plugin-lifecycle-source.ts:56
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winClear displayed-root attention when lineage lookup fails.
If a child blocker is displayed on the root and
resolveRootSessionIDreturns null for the root’s idle event, this branch clears only records whosesourceSessionIDis the root. The child blocker remains pending, so the pane can stay on “needs input” after the root turn ends. UseclearAttentionForTurnEndhere too; its source-or-displayed-session match preserves exact child cleanup while retiring blockers displayed on the ending root.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 76695dfe-48cd-414b-baa4-881586510467
📒 Files selected for processing (4)
src/main/opencode/hook-plugin-opencode2-session-lineage.test.tssrc/main/opencode/hook-service.test.tssrc/main/opencode/status-plugin-lifecycle-source.tssrc/main/opencode/status-plugin-ownership-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
ℹ️ Minor suggestions only — one test-comment wording nit; the lifecycle change itself is sound and well-tested.
Reviewed changes
- Wider attention clear at root turn end —
clearAttentionForTurnEndmatches either the blocker'ssourceSessionIDor the rolled-up displayproperties.sessionID, so a descendant blocker shown on the root is retired when the root goes idle. - Call site scoped to the idle branch —
status-plugin-lifecycle-source.ts:117uses the wider clear; the root-going-Busy path keeps the source-only clear so a live subagent blocker still outranks Busy. - Digest updates —
hook-service.test.tsdigests move for the opencode and mimo-code families, as expected from the shared ownership source. - New lineage test —
retires a child raised blocker when the root turn goes idle; I mutation-reverted the lifecycle call toclearAttentionForSessionand confirmed it fails (expected 'AskUserQuestion' to be 'SessionIdle'), so the test pins real behavior.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
|
||
| // Why this case: it is the shape reported in #22371 — a subagent asks, the lead | ||
| // agent truthfully reports no pending question, and the pane stays "needs input" | ||
| // with nothing able to clear it. With lineage unresolved the blocker keys to the |
There was a problem hiding this comment.
The With lineage unresolved clause misstates the mechanism. The blocker keys to the child because attentionKey uses the child's sourceSessionID, not because resolution failed — and in the genuinely unresolved case properties.sessionID is also the child, so this fix would not retire it either. Describing it as the source-versus-display id split would avoid implying the unresolved path is covered.
There was a problem hiding this comment.
Understood — leaving the comment to track the reported scenario (#22371) rather than the resolved-lineage mechanism this test actually exercises.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thanks — I chased the outside-diff finding at That branch runs when I tried two ways to reach it and both refuted the concern:
So the guard would be defence against a state I can't produce. I removed a similar unprovable guard from #22548 after review showed the collision it defended was ruled out by the key structure, and I'd rather stay consistent than carry a second one — especially with a If you can construct a sequence that reaches that branch with a root-displayed blocker outstanding, I'll take the change immediately — it's a one-line swap and costs nothing at runtime. I just don't want to ship it justified by a scenario I couldn't demonstrate. The core fix and its test are unchanged and both mutation-verified: reverting @pullfrog — noted on the test-comment wording nit; leaving it as-is since the comment describes the reported scenario rather than the mechanism, which is what I wanted a future reader to match against. |
|
I took the invitation to construct it, and the branch is reachable. The one-premise-of-the-argument that breaks is "success is cached by
I reproduced it end to end: mint the child's blocker on the root, insert 130
So it is not defence against an unreachable state — it closes the one path where the cache-only assumption breaks under the SDK outage this branch is for. Opened #22615 with the one-line swap and a regression test (
|
…tablyai#22604) A descendant's question is stored under its own sourceSessionID but displayed on the root session it rolls up to. clearAttentionForSession matches only the source, so the root's own idle could never retire it: the blocker outlived the turn that raised it and pinned the pane on "needs input" with nothing left to answer. The lead agent truthfully reports no pending question, because the blocker belongs to a child it does not know about (stablyai#22371). Add clearAttentionForTurnEnd, matching the source id or the rolled-up root, and use it only from the idle branch. Scoped to turn end deliberately: a live blocker must still outrank the root going Busy, since a subagent can be waiting on the user while the root keeps working — widening the existing clear broke exactly that test, which is what surfaced the right scope. Shared with the OpenCode family, so mimo-code gets the same fix; both pinned plugin digests move. New test fails without the change: after the root turn ends the last post is still AskUserQuestion instead of SessionIdle. (cherry picked from commit 8ddad49)

ELI5
When a subagent asks you a question, Orca shows "needs input" on the pane — correctly, because something really is waiting on you. But if that turn ends without the question being answered, the indicator never went away. Nothing could clear it, and the main agent would tell you it has no question, because the question belonged to a subagent it doesn't know about.
What Changed
clearAttentionForSessionmatches blockers only bysourceSessionID. A descendant's question is stored under the child's own id but displayed on the root it rolled up to, so the root's own idle never matched it and the blocker survived the turn.Adds
clearAttentionForTurnEnd(sessionID, factoryID), which matches either the source id or the rolled-up root, and uses it from the idle branch only.Before: root turn ends → last post is still
AskUserQuestion; the pane stays blocked.After: root turn ends →
SessionIdlefor the root; the pane settles.Why
This is the mechanism behind #22371, and it reproduces deterministically:
It matches every fact in that report: the indicator appears (a subagent genuinely did ask), the lead agent truthfully says it has no pending question (the blocker belongs to a child it doesn't know about), and nothing clears it. The reporter's "workaround" of switching Orca tabs worked because unmounting deletes the row wholesale — that's #22445, a separate defect, and it's why this looked like a UI-state bug rather than a lifecycle one.
Why scoped to turn end rather than widening the existing clear. My first attempt widened
clearAttentionForSessionitself. That brokeclears only the matching child reply or rejection and preserves root Busy— because the busy branch also calls it, and a live blocker must outrank the root going Busy: a subagent can be waiting on you while the root keeps working. That failing test is what identified the correct scope, so the narrow variant is deliberate, not incidental.Alternatives considered:
Linked Issue
Fixes #22371
Visual Proof
N/A— and worth stating why, because an earlier attempt at this issue produced a misleading one.The user-visible change is an indicator disappearing at the end of a turn. A before/after screenshot of the blocked moment is identical in both builds (the indicator correctly appears in both); the difference only shows after the turn ends, where "after" is an absence. I previously captured before/after shots for #22444 that looked identical and correctly concluded they proved nothing — the same trap applies here.
The proof is the hook-post sequence, which is exactly what the pane renders from:
Testing
retires a child raised blocker when the root turn goes idle— root starts a turn, a child raises a question form, the root turn succeeds. Asserts the final post isSessionIdlefor the root.Mutation-checked: swapping
clearAttentionForTurnEndback toclearAttentionForSessionfails it (both plugin variants), with the last post stillAskUserQuestion.pnpm test src/main/opencode src/main/opencode2 src/main/agent-hooks src/main/mimo→ 114 files, 1258 passed, 9 skippedpnpm tcclean;pnpm run check:code-quality:changed→ 0 findingsBoth pinned plugin digests move, including
mimo-code's — the ownership source is shared across the OpenCode family, so MiMo Code gets the same fix. That is intended, not collateral: it has the same subagent rollup.Not verified: that this resolves the reporter's exact frame on their machine. I could not reproduce their original attribution (the Subagents dock emits no events at all — proven earlier with a real TUI capture), so this fixes the mechanism that matches their description, not a reproduction of their session. Worth their confirmation before considering it closed.
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
docs/reference/agent-status-store.md.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally