Skip to content

fix(runtime): guard background subagent recovery across processes - #307

Open
kingsword09 wants to merge 1 commit into
mainfrom
fix/306-subagent-execution-ownership
Open

kingsword09 wants to merge 1 commit into
mainfrom
fix/306-subagent-execution-ownership

Conversation

@kingsword09

Copy link
Copy Markdown
Owner

Closes #306.

After an abrupt exit, resuming the parent session registered saved subagents as active tasks. The task center offered to stop them, and the native stop path threw when it received a numeric timestamp from the session projection.

This change reads historical tasks through the runtime's subagent query and keeps their results available to TaskOutput. Stopping a live agent requires its current execution ID, so a stale request cannot cancel a later run.

Each new child execution holds an exclusive SQLite lock in its output directory. A second CLI can inspect the task while its owner is alive. After a crash releases the lock, an explicit resume can continue the saved child session. Legacy running records with no verifiable owner are shown as owner_unknown.

Verification

  • bun run release:build passed with the locked 4.0.0 runtime.
  • A real two-PTY test against a local SSE endpoint verified that both /tasks resume and model-issued SendMessage leave the first client's stream alone. After killing the owner, the second client resumed the child and stopped its new stream.
  • Node regressions covered simultaneous resume attempts, stale stop and restart requests, and historical output reads without live registry writes.

@github-actions

Copy link
Copy Markdown
Contributor

pkg-pr-new preview for commit 1b96d0194298adc90524d27cae1c45df675f2e96.

npx --yes https://pkg.pr.new/zcode-app-cli@1b96d01

Full repository URL

This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with /pkg-pr-new.

Workflow logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background subagent stays running after a crash and /tasks stop throws

1 participant