[BUG] opencode-http (2.x): turn end acted on after `descendant-wait-ended` while the parent was already re-woken by the child's `<subagent>` message
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in adapters/opencode_http.py at the if event == "idle": branch of _wait_loop (around line 1760), then read _await_descendants and active_descendants together with the session_busy and execution-event handling. Compare those paths against the descendant-wait-ended and session-end entries in tasks/<task>/session-lifecycle.jsonl from the two sessions to see where the stale idle is acted on. Done looks like the waited turn end is re-validated, by checking whether the parent is busy again or a new session.execution.started arrived, before _result_json(..., wait=True).
索引モデルが issue の本文から書いたものです。
説明
Environment
- bmad-loop
8224d53(main, 2026-11-17;--version0.13.2), installed withuv tool installfrom git. The descendant wait (#1030) is not in any release yet: v0.13.2 has no_await_descendants. - Adapter
opencode-http, OpenCode server 2.3.2 (opencode serve) - macOS, tmux backend
- Dev model
opencode-go/muse-spark-1.3-contributor, stories mode,bmad-build-auto
Summary
On OpenCode 2.x every subagent call runs in the background (2.3.2 tool description: "Subagents always run in the background … you receive a <subagent> message each time the child goes idle"). The dev skill delegates the review-patch work to a subagent, so the parent ends its turn and _await_descendants (#1030) holds the turn end until the child is idle.
When the child finishes, OpenCode delivers its <subagent> result into the parent's inbox and restarts the parent (session.inbox.enqueued → session.execution.started → session.inbox.delivered). _await_descendants then probes, sees no active descendant, journals descendant-wait-ended and returns True. The wait loop treats the old idle as the turn end and returns completed. But by then the parent is running again: it was about to re-verify, set the spec to done and commit.
The engine then reads the spec at a nonterminal status and decides retry/defer ("spec remained at reconcilable nonterminal status 'in-review'/'in-progress' while harvesting deferrals"). The attempt is rolled back, even though implementation and review were complete.
Evidence (two sessions, same run)
Times are the SSE frame ts; the descendant-wait-* entries come from tasks/<task>/session-lifecycle.jsonl.
15-dev-1
| ts (s) | event |
|---|---|
| 1795181693.681 | parent session.execution.succeeded (turn ended, awaiting the patch subagent) |
| 1795181693.687 | descendant-wait-started sessions: [<child>], grace_s: 600 |
| 1795181937.635 | parent session.inbox.enqueued (<subagent … state="completed">), session.execution.started, session.inbox.delivered |
| 1795181938.620 | descendant-wait-ended waited_s: 244.9 |
| 1795181938.673 | parent session.step.started (the parent is working) |
| 1795181938.715 | journal session-end status: completed → dev-decision retry |
16-dev-1
| ts (s) | event |
|---|---|
| 1795183575.596 | parent session.execution.succeeded |
| 1795183575.606 | descendant-wait-started |
| 1795183743.452 | parent inbox.enqueued / execution.started / inbox.delivered |
| 1795183743.471 | descendant-wait-ended waited_s: 167.9 |
| 1795183743.504 | parent session.step.started |
| 1795183743.547 | session-end completed → dev-decision retry |
In both sessions the parent's transcript ends on the delivered <subagent> message, with no assistant turn after it.
In this case the child was a follow-up to an existing subagent: the call passed sessionID to resume the earlier implementation child, so the child ID was the same one the earlier waits had already seen finish.
Where
adapters/opencode_http.py, the if event == "idle": branch of _wait_loop (around line 1760): when _await_descendants returns True, the loop goes on to _result_json(..., wait=True) with nothing showing that the parent is still settled. _await_descendants only asks active_descendants; it never checks the parent again.
Expected
After a descendant wait that actually waited (descendant-wait-ended), the turn end should be re-validated before it is acted on. For example: if the parent session is busy again (session_busy → True), or a session.execution.started for the parent arrived during the wait, discard the stale idle and keep waiting for the next turn end.
Related
- #1030: added the OpenCode subagent wait; this is an edge of that wait.
- #109: the same "yield to await a background subagent" pattern on the Claude adapter.
Side note
With the default dev_stall_grace_s = 600, a long implementation subagent (>10 min) also expires the wait (descendant-wait-timeout) and the parent's stale turn end is acted on in the same way. Raising the grace to 2400 s avoided that, and the next story completed. It does not close the race above.
- 主要言語
- Python
- スター
- 196
- フォーク
- 78
- 平均マージ
- 9時間 24分
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bmad-code-org/bmad-loop のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bmad-code-org/bmad-loop#1063 ·
メンテナーはふだん 1 日以内に返信
-
psmux: task window name starting with '-' creates no window; session reads as crashed対応中かも @RECOHA が 8 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
bmad-code-org/bmad-loop#1061 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
bmad-code-org/bmad-loop#1057 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
bmad-code-org/bmad-loop#973 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bmad-code-org/bmad-loop#965 ·
メンテナーはふだん 1 日以内に返信
bmad-code-org/bmad-loop の issue をすべて見る
似ている issue
-
DMB documentation good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ubuntu/ubuntu-project-docs#921 ·
メンテナーはふだん 1 日以内に返信
-
⏳ Pending feedback 🐛 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
jumpserver/jumpserver#18282 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/loom#2014 ·
メンテナーはふだん 1 日以内に返信
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
future-agi/future-agi#5274 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信