Repository navigation
fix(session): re-arm finished runs when messages land in the idle window (#32) - #34
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Note on the |
…dow (#32) The run loop's exit decision reads messages at the top of each iteration, but the transition to idle happens later inside Runner.finishRun's SynchronizedRef section. A message written between the last read and that transition (background subagent completions land there reliably) was judged against a stale snapshot and dropped: the writer's ensureRunning saw Running and its join branch discarded the passed work, so nothing consumed the message until the next external trigger. Give Runner.make an optional shouldReArm predicate, consulted inside finishRun's critical section: on a successful exit (interrupts and failures must not resurrect the run), a true predicate restarts the same work instead of going idle. Session passes a predicate that re-reads the persisted messages — latest user newer than latest assistant — so every idle decision sees writes that landed after the loop's last read. Predicate read failures fall back to false (pre-fix behavior). Co-Authored-By: Claude <[email protected]>
issue #32 的 §7.1 修正方案文档(根因/V2 settle 对照/正确性论证/测试与代码清单回填) 及开发日志(含度量段)。 Co-Authored-By: Claude <[email protected]>
40a1d43 to
58dd62c
Compare
|
合并进 #35 的分支了,这个 PR 关掉。
为什么走这条路:#32 的 lost-wake 窗口正好在 #35 依赖的东西底下 —— 一条已投递的消息落在 run 收尾的间隙里就无处可去,而 两边都改了 合并后在 |
fmv1 was the baseline set in #31 after the upstream sync. This branch adds the agent management surface and carries the idle-race fix from #34, so the fork suffix moves on. The upstream base is unchanged at 1.18.25, and package.json still belongs to upstream's sync release versions commits — the build reads OPENCODE_VERSION and nothing else, so FORK_INSTALL.md is the only place this lives.
Closes #23. Closes #32 — the fix from #34 is merged in here. A model launches, sees, messages and stops subagents through four tools: `agent`, `agent_list`, `agent_send`, `agent_stop`. The `task` tool is gone. Delegation is always asynchronous: `agent` returns once the subagent has started and its result arrives later as a message. `agent_send` is one-way and also resumes an idle or stopped agent. `agent_stop` cascades to descendants and deletes nothing. Nesting is bounded at three by default, and at the limit the spawning tools are withdrawn rather than offered and refused. Each subagent gets its own git worktree and is told to use it — advisory, not a sandbox (#33). Recorded rather than closed, all in the TUI's subagent surface: #37 a subagent session cannot be typed into, #38 there is no subagent list, #39 Agent notices render three different ways. Includes one upstream cherry-pick, `test(app): retire legacy layout e2e coverage` (7f20943), without which e2e cannot pass on any branch.
Issue for this PR
Closes #32
Type of change
What does this PR do?
The run loop decides to exit from the message snapshot read at the top of each iteration, but the transition to idle happens later inside
Runner.finishRun'sSynchronizedRefcritical section. A message written in between (background subagent completions reliably land there) is judged against the stale snapshot and dropped: the writer'sensureRunningsees Running, its join branch discards the passed work, and nothing consumes the message until the next external trigger.Fix follows the issue's re-arm proposal:
Runner.maketakes an optionalshouldReArmpredicate, consulted insidefinishRun's critical section. On a successful exit (Exit.isSuccesscovers both guards the issue asks for: interrupts and failures must not resurrect the run) a true predicate restarts the same work instead of going idle. Session passes a predicate that re-reads the persisted messages — latest user newer than latest assistant, the narrow form so stop-paths without a finish don't re-arm into extra provider calls; read failures fall back to false. Writers need no coordination since the signal is the persisted message row itself. Root-cause analysis and correctness argument:docs/fixes/session-runner-fix-idle-race.md.How did you verify your code works?
bun run test:httpapigates: 208/0 in all three modes. Full package suite failure set is identical to the pre-fix baseline (28 pre-existing failures, none introduced).bun run typecheckpasses.Screenshots / recordings
Not a UI change.
Checklist