Repository navigation
Conversation
Hold the lead Stop through the shared child-work fold while UUID children are live between SubagentStart and SubagentStop. A child that sends no hook for 10 minutes stops holding the row. Interrupt (subscribed async, as Muse requires), SessionStart and SessionEnd clear tracked children, and the existing transcript-poll replay of the held Stop then reaches done. Fixes #28090
Best-effort layer on top of the subagent hold. A workflow starts holding
the row from the documented `workflow` PostToolUse result
({status: "launched", taskId}) and stops on the first of: its task
settling (completed/failed/cancelled) in Muse's undocumented session.jsonl,
or the Stop of the run Muse wakes the lead in. It also yields to the
10-minute inactivity limit, Interrupt, SessionStart/SessionEnd, and an
unreadable log. Only live hooks start tracking, so work logged by an
earlier Muse process can never hold a resumed session.
Refs #28090
nwparker
changed the base branch from
fix/muse-background-subagents-done
to
main
November 7, 2026 04:36
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Parked as a draft, not planned to merge. It depends on Muse's undocumented session log (
session.jsonl), so any Muse release could change that format and quietly break workflow status. It also has known gaps: overlapping workflows turn done together when the first finishes, and pressing Esc doesn't stop a workflow, so the row stays working until the workflow actually ends. #38911 already covers background subagents using documented hooks. Next step: ask the Muse team for a documented workflow-completion hook, then redo this on top of it.Refs #28090
Linear: STA-10361
What this adds
#38911 holds a finished Muse turn open while a spawned background subagent runs, using documented hooks only. Muse workflows (the
workflowtool) need more: the lead'sStopcomes before the first workflow agent'sSubagentStart, and Muse fires no hook when a workflow ends. This PR adds a best-effort workflow hold:workflowtoolPostToolUseresult{"status":"launched","taskId":…}. Only a live hook starts tracking; nothing in the log can start it.session.jsonl) settling thattask_idascompleted,failedorcancelled;Stopof the run Muse wakes the lead in (a run with noUserPromptSubmit).Interrupt,SessionStartandSessionEnd;transcriptPollUpdatenow also republishes on aworkingModechange.kill -9) leaves itsworkflow.run.nativetask atstartedforever. Tracking only starts from live hooks, andSessionStartclears it, so that stale record can never hold a resumed session.How a workflow ends is read from Muse's
session.jsonltaskrecords (payload.kind: "task",payload.task_id,payload.event.kind). This is not a documented interface. The fallback, if a future Muse version stops writing those records or changes their shape:Stop(a hook), or until 10 minutes pass without child activity.Live verification (real Muse Code 1.4.14 TUI)
Muse ran in tmux in a scratch directory with Orca's generated managed hooks file. Every hook was posted to a real
AgentHookServerbuilt from this branch:sleep 40workflowStop22:42:47 → working (monitoring); agent starts → working;SubagentStop22:43:34 → monitoring; logcompleted→ done 22:43:36; wakeStop22:43:39 → donesleep 120workflowInterruptand kept the workflow running) → done 22:50:22 when it finished/exit→ "Exit anyway" with a workflow runningSessionEnd(reasonother) 22:51:13 → done 22:51:14Headless trace (
muse exec): the launchtaskIdmatched the log'sworkflow.run.nativetask. Itscompletedrecord came 0.6 s after the agent'sSubagentStop, and 14 s before the wake run'sStop.Tests
server-muse-session-log-poll.test.ts: a launched workflow holds the row in monitoring until the log settles it. The hold is also released if the log disappears.muse-events.test.ts: the wake run'sStopends a workflow the log never settled.Checks
pnpm tcpasses.src/shared/agent-hook-listener,src/main/agent-hooks,src/main/muse,src/wsl-guest,src/shared/agent-status,muse-session-log(243 files, 1541 tests).ORCA_CODE_QUALITY_BASE=origin/fix/muse-background-subagents-done pnpm check:changed: 24 of 25 checks passed. The unit-test check failed. It selects the whole cross-version / runtime unit set, and four tests failed under machine load:orcad-chat-restart-offer, tworuntime-rpc-long-poll-transportkeepalive tests, and onecross-version-agent-session-wiretest. Re-run on their own with--maxWorkers=2, all three files passed (54/54). None of them touch Muse code.Known limits
Stopreleases every workflow launched in earlier runs, so two overlapping workflows can release together when the first one ends.Interrupt, so the row stays held until the workflow ends. That matches what Muse is doing.