mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4218] [GUI] Stopped background helper keeps its In progress row after a restart #1855
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1855
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xvcezrqpbxtpzblrt on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4218
2026-11-06 核对结果:装机 0.2.11(dist)与 main@9f7d977d2 源码中已存在该修复——重启加载时 settleAgents 把仍标 working 的 helper 行标为 cancelled(agents.ts,注释含 #4218)。未做 GUI 实测。可关单;如再复现请带场景。
Area
[GUI] (the desktop app)
Desktop app, Terminal or source?
Desktop app (Windows, Linux or Mac)
What happened
I started a chat on a local model and let the agent start a background helper agent that ran a long tool call. The parent turn ended while the helper was still running; the chat header showed one running helper and the helper row said "In progress".
I pressed Stop while the helper was still running. The helper did stop: its session ends with
turn/end(reasonaborted, sourceuser), and a laterlist_agentscall returns it as[inactive]. The helper row in the chat, however, stayed "In progress" permanently, and the header kept counting one running helper. Quitting and reopening the app did not clear it.Expected: once the helper ends, the row becomes "Cancelled" (or "Stopped") and the running count drops to zero. At the latest, a restart must not restore a "working" row for a helper that is not running.
Actual: the row stays "In progress"; its duration freezes at the last row update (48m46s in my run) although the helper ran 52m53s; the persisted browser state still has
status: "working"for that row; a restart restores it unchanged.Smallest steps or command that reproduce it
I reproduced this once. I did not repeat it on a second run; the persisted state and the restart behaviour were consistent across the app restart I tested.
Reproduction status
Reproduced locally
Strata version
Strata 0.2.6 (desktop) · engine 0.1.50
Graphics card, memory and system
NVIDIA GeForce RTX 3080 Ti Laptop GPU, 16 GB VRAM · 64 GB RAM · Windows 11 Pro
Model, size and settings
Local model, 512K context, KV q4_0, one request slot. Pictures off. The helper used the same local model.
Logs
No log file is attached. The evidence is the UI state and the session events, with relative times:
turn/endreasonaborted(user).list_agentsreturns the helper as[inactive].The persisted browser state for the row contains
status: "working",durationMs: 2926057and anupdatedAtequal to the last row update (T+48m46s). The helper's own session log ends at T+52m53s withturn/end(aborted,user), so the helper is not running.Code reading (inference, not a measurement)
I read the 0.2.6 tree. Line numbers may move.
apps/host/server/agent/children.mjs:163-169mapsturn/endwith anabortedreason tocancelled, andapps/host/server/agent/agent-bridge.mjs:578emits the final row.apps/host/src/lib/agents.ts:7-25andapps/host/src/lib/store.ts:688/1785. There is no path that changes aworkingrow when a turn ends or when the app starts.loadSessions()(apps/host/src/lib/store.ts:170-187) restoresagentsunchanged; it only clearsmessage.streaming.finishTurn()(apps/host/server/agent/agent-bridge.mjs:471-477) closes the child follow streams. It does not emit a terminal row for a child that is stillworking.So the deterministic gap is on the frontend: a persisted
workingrow survives every restart. The terminal row was not applied in my run; I did not instrument the host to find where it was lost, so I am not claiming a specific drop point.Suggested fix
The smallest fix is to reconcile on load: in
loadSessions(), change anyagents[*].status === "working"tocancelledunless the host reports that session as running. A second fix is to reconcile at the end of a run: infinishTurn(), emit a finalcancelledrow for every child that is still notdonebefore closing the streams. Either one removes the permanent "In progress" row; the first also covers a crash or a closed window.Impact
The row and the "N subagents running" count stay wrong until the browser state is cleared or the app is reinstalled. New turns and new helpers work; only the old row is stuck. Because the row is persisted, a restart does not help, which makes it look like the helper is still running.
@xvcezrqpbxtpzblrt commented on GitHub (Oct 27, 2026):
Additional evidence and a narrower root cause (0.2.6, code reading + the same reproduced run)
I re-checked the 0.2.6 tree and the installed app. The installed
host/server/agent/agent-bridge.mjs,children.mjsandprofile.mjsare byte-identical to the 0.2.6 source, so this is not an old-build artifact.In the reproduced run, the persisted row is still
working; the helper's own log ends withturn/end(aborted,user) 4m7s after the row's last update. The row'sdurationMsis 2,926,057 ms (48m46s), while the turn ran 52m53s. A restart restores the row unchanged. Two other helpers stopped in the same app session did get a terminal row, which is consistent with a race rather than a missing status mapping.What the code does (static analysis, not instrumented):
finishTurn()(agent-bridge.mjs:471-477) setsturn.finished = trueand closes every childsession/followstream. It does not emit a terminalagentframe for a child that is stillworking.fold()(agent-bridge.mjs:572) starts withif (turn.finished) return, so a childturn/endthat arrives after the parent turn finished is ignored.stop()(agent-bridge.mjs:1290-1308) interrupts helpers first, then cancels the parent; a 300 ms settle timer and the parent's ownturn/endcan finish the turn before the child's terminal event is folded.agents.ts:7-25); it has no terminal-absorbing rule.loadSessions()(store.ts:170-187) restoresagentsunchanged, and the rows are persisted tolocalStorage(store.ts:1016).runningAgents()countsstatus === 'working'(agents.ts:27).So the exact drop point in this run is not proven without host instrumentation, but the class of failure is deterministic: once the terminal row is lost, nothing reconciles it, and the persisted
workingrow survives every restart.The load-time reconciliation needs a host snapshot, not only a per-session running flag:
The suggested "unless the host reports that session as running" check is the right direction, but the host needs to expose the live child set, not only a session-level boolean. Otherwise a webview reload while the host keeps running can still mark a live helper as cancelled, and a lost terminal frame can still leave a row
workinguntil the next reload. The load path should ask the host for the live child rows (a snapshot) and only mark rows that the host does not report as live. The same snapshot should be used after a stream gap/reconnect. A terminal row should also be emitted before the child stream is closed, and the UI merge should treat terminal states as final.I did not instrument the host, so I am not claiming which of the three windows above fired in this run. The reproduced facts are the persisted
workingrow, the childturn/end, and the restart behavior; the code paths are static analysis.@xvcezrqpbxtpzblrt commented on GitHub (Oct 30, 2026):
Still present in 0.2.8, and unchanged on
main.Not a re-test — a check that nobody fixed it by accident. Four of the files that own this were compared at tag
v0.2.6andv0.2.8(and the installed 0.2.8 copies are byte-identical to the tag):apps/host/server/agent/children.mjs,apps/host/src/lib/agents.ts,apps/host/src/components/SubagentRow.tsx,apps/host/src/components/ChatToolbar.tsx— SHA-256 identical across both tags for all four. The v0.2.6, v0.2.7 and v0.2.8 notes never mention subagents or helper rows.What is confirmed by reading the shipped 0.2.8, beyond what is already in this issue:
apps/host/src/lib/store.ts:186loadSessions()restoresagentsuntouched — it only clearsmessages[].streaming.bootOnce()reconciles time-skips, loops and tool cards (:2017,reconcileAgentToolsat:2025) but has no equivalent foragents, andreconcileAgentToolsonly asks/api/agent/pending, which knows about approvals, not children. So astatus:"working"row comes back forever.SubagentRow.tsx:20then keeps addingnow - updatedAtto its duration while the status isworking, andChatToolbar.tsx:32counts it as running, so the header reads "N subagents running" for a helper that stopped hours ago.agent-bridge.mjs:568region) that dies with the turn, and the bridge's exported surface (:1336) offers onlyisRunning(chatId)/ pending helpers — there is no "which children are live" call for a load-time reconcile. That is the same gap my 2026-10-27 note in this issue pointed at, and 0.2.8 did not close it.finishTurn(agent-bridge.mjs:471-473) marks the turn finished and closes the child follow streams without emitting a final row for a child stillworking;fold()refuses everything once the turn is finished (:572), so the child's laterturn/endis discarded and the terminal mapping inchildren.mjs:163-169never runs; the Stop path (:466interrupts children, then the parent) races the 300 ms settle timer; and rows are throttled to one per 400 ms (:557) with the flush timer stopped as soon as the turn is finished (:595), so a pendingworkingrow can be the last thing ever sent. The settle loop at:744-750(which keeps the turn open up to 8 s for a child that has not been noticed) makes the normal case arrive — which matches the observation that most helpers do get a terminal row and this one raced.apps/host/src/lib/agents.ts:12-13discards the whole frame when itsupdatedAtis older than the stored row's, so a terminal row emitted after a newerworkingrow is thrown away rather than applied. Worth checking before deciding which of the four windows matters in practice.On the second half of the complaint — whether the assistant itself knows. It does get told, and not by polling: the harness splices a model-visible line into the parent ("Background subagent finished and will do no further work unless you send it more." / "…was stopped before it finished."), and
agent-bridge.mjs:636-637recognises exactly that text to mark a childnoticed, with:750holding the run open up to 8 s waiting for it. Two caveats I can state as code but not as observation: the parent's delegation traffic is deliberately hidden from the transcript (apps/host/server/agent/events.mjs:20NO_CARDcoverssubagent,send_message,list_agents), so the person never sees that exchange; and if the parent's turn has already finished (turn.finished, checked at:452and:572) a settlement that lands late has nowhere to render. So the misleading part is the row, not the model's knowledge — which is worth keeping in mind for the fix's scope: a client-side reconcile plus a host snapshot of live children covers it, and the terminal-state merge inupdateAgentshould not let a stale non-terminal frame win.No new reproduction was run on 0.2.8 — the stuck row here is the 0.2.6 measurement already in this issue, and the list above is what the shipped 0.2.8 code does.