Repository navigation
fix(core): background subagents resume after a server restart instead of showing cancelled - #58261
Open
kitlangton wants to merge 7 commits into
Open
kitlangton wants to merge 7 commits into
kitlangton wants to merge 7 commits into
Conversation
kitlangton
force-pushed
the
subagent-recovery
branch
from
October 24, 2026 19:32
ac45827 to
2a98174
Compare
kitlangton
force-pushed
the
restart-notice
branch
from
October 24, 2026 19:32
34e161d to
105add5
Compare
kitlangton
force-pushed
the
restart-notice
branch
from
October 24, 2026 19:44
105add5 to
17a0f65
Compare
kitlangton
force-pushed
the
subagent-recovery
branch
from
October 24, 2026 19:44
2a98174 to
30ffe8e
Compare
kitlangton
force-pushed
the
restart-notice
branch
from
October 25, 2026 16:33
17a0f65 to
efc61e5
Compare
kitlangton
force-pushed
the
subagent-recovery
branch
from
October 25, 2026 16:33
30ffe8e to
c24d528
Compare
kitlangton
force-pushed
the
subagent-recovery
branch
from
October 25, 2026 18:34
c24d528 to
cb30ef6
Compare
kitlangton
force-pushed
the
restart-notice
branch
from
October 26, 2026 17:49
a1b4eb7 to
8ec9ecd
Compare
3 of 6 tasks
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.
Background subagents now pick up where they left off after a server restart, instead of showing "Subagent cancelled" and losing their work.
A background subagent is a child agent a session starts and leaves running; when it finishes, its result lands in the parent session. Stopping a subagent on purpose still cancels it, as before.
🔍 Origin: seen in real use: after a clean server restart, every background subagent that was still working showed "Subagent cancelled" and none resumed.
❌ Before
sequenceDiagram participant P as Parent session participant S1 as Server (shutting down) participant DB as Database participant S2 as Server (next start) Note over S1: Clean shutdown, child still working S1->>P: ❌ "Subagent cancelled" S1->>DB: ❌ clear the child's "running" marker S2->>DB: find "running" markers DB-->>S2: none, child is never resumed✅ After
sequenceDiagram participant P as Parent session participant S1 as Server (shutting down) participant DB as Database participant S2 as Server (next start) participant C as Background child rect rgb(220,245,220) Note over S1: Clean shutdown counts as a pause Note over DB: "running" marker kept, no result sent S2->>DB: find "running" markers S2->>C: resume the child once C-->>P: real result, delivered once endAlso, background subagent handling is now set up once for the whole server instead of once per project, so reloading a project no longer drops the watchers that deliver results.
📊 Proof
With the source changes reverted and the tests kept, the two-process test and the permission-prompt child case fail. 77 core tests pass.
👀 Read:
packages/core/src/job.ts, the shutdown cancel path. While the old server is shutting down it sees the job as "cancelled" but the database still says "running", so any new code reacting to a cancellation must check its reason (subagent-completion.tsdoes). Not checked live in the desktop app. The rest is routine: shared result reading insubagent-completion.ts, a one-line call change inexecution.ts, registering the service app-wide inpackages/server/src/routes.ts, and tests.Stacked on #58260: merge that first, then this retargets to
dev· no schema or saved-format changesChecks run
Run on this head, on top of #58260:
packages/core:bun typecheckpasses.bun test test/permission-restart.test.ts test/session-projector.test.ts test/session-execution.test.ts test/job.test.ts test/session-restart-process.test.ts: 77 pass.packages/server:bun typecheckpasses.bun script/lint-changed.ts origin/dev: 0 problems.session-restart-process.test.tsand the pending-permission child case inpermission-restart.test.tsfail.