Repository navigation
Conversation
Reuses the existing isSessionRunningForReplacement() pattern (already used by clone/fork in rpc-manager.ts) for the paths that can still invalidate a live extension ctx mid-turn: - `reload` via the extension command API and the extension ctx callback object (rpc-manager.ts) - previously unguarded, unlike clone/fork - the cwd-scoped sweep destroyRpcSessionsForCwd() shut down every session in the target cwd, including running ones - DELETE /api/sessions/[id] shut down the deleted session's subagent descendants and the target even while they were mid-turn - a background subagent outlives its parent's turn, so the parent session could be idle-evicted while the run was still active; register a session-liveness provider for the parent for the run's lifetime (start()/resume() in subagent-runtime.ts), released when the run's promise settles Also updates the source-assertion test for the DELETE route to the guarded shutdown form. Verified against a locally built 0.11.1: a reload aimed at a session with an in-flight turn is now rejected and the turn completes; idle sessions still reload/delete normally; a parent holding a long background subagent survives the idle window and receives the completion notification without a stale-ctx failure. Refs agegr#1172
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.
Reuses the existing
isSessionRunningForReplacement()guard (already used byclone/forkinlib/rpc-manager.ts) for the paths that could still tear down a session while it had an in-flight turn. That teardown is what leaves extensionctxobjects stale mid-run (see #1172).What was unguarded
lib/rpc-manager.ts) — the extension command API and the extensionctxcallback object reloaded without checkingisSessionRunningForReplacement(), unlikeclone/fork.lib/rpc-manager.ts) —destroyRpcSessionsForCwd()shut down every session in the target cwd, including running ones.DELETE /api/sessions/[id](app/api/sessions/[id]/route.ts) — shut down the deleted session's subagent descendants, and the target, even while they were mid-turn.lib/subagent-runtime.ts) — a background subagent outlives its parent's turn, so the parent was eligible for idle eviction while the run was still active.start()/resume()now register a session-liveness provider for the parent, released when the run's promise settles.Verification
Built 0.11.1 locally and exercised:
npm run typecheckandeslintare clean, andnode --test lib/rpc-manager.test.mjspasses (the DELETE-route source assertion was updated to the guarded form).Three failures in
lib/mcp-test.test.mjs,lib/mcp-transport.test.mjsandlib/rotate-preview-secrets.test.mjsalso reproduce on a clean30af3b4checkout in this container (running as root, so the read-only-dir case cannot behave as intended, plus process-reaping timing). They are unrelated to this change.