You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Session forks can retain task-part references to the source session's subagent sessions. Continuing a copied task then runs the original child session, so activity, permission prompts, and state can leak between the source and fork. This affects every editor flow using the generated SDK fork endpoint, including the sidebar, Agent Manager LOCAL sessions, Agent Manager worktrees, and Continue in Worktree.
The isolation behavior originally introduced in #8956 regressed in two migrations:
daaa2e5911 introduced the Effect HttpApi lifecycle handler and called the raw Session.Service.fork() operation directly. That bypassed the Kilo wrapper responsible for cloning and remapping task child sessions.
e4c9b4363e converted the remapper to Effect services but lost the graph-wide source-to-copy map, its root seed, and the cyclic-session regression coverage. Self-references and cycles were no longer safely remapped.
This restores isolation at the shared server boundary used by editor clients. The HTTP fork wrapper now remaps task child-session references after creating the root fork, while direct CLI forks retain the same behavior. A single graph-wide map is seeded with the source and copied roots, reused through recursive child forks, and used to rewrite task metadata. This makes each referenced subagent independent, deduplicates repeated references, and terminates self-referential or cyclic graphs.
Regression coverage now exercises the generated SDK against the real HTTP route used by Agent Manager, and restores nested, self-referential, and cyclic session graph cases. A patch changeset records the restored user-facing behavior.
The fix correctly restores subagent isolation at both the HTTP boundary (forkRaw) and the CLI path (kiloSessionFork). The graph-wide remapped map is seeded with the [sourceID → forkedID] pair before recursive remapping, which correctly handles self-referential and cyclic session graphs, and deduplicates repeated references.
One non-blocking observation (not in diff):
In fork.ts:51, the guard if (remapped.size === 0) return is now dead code for all callers — the map is always pre-seeded with at least one entry. It's harmless (the update loop handles the empty-refs case via continue), but the log on line 69 will always report count >= 1 even when no children were actually copied (just the seed entry). Not a bug, just slightly misleading. Consider removing the guard and adjusting the log to track actual forks rather than map size, in a follow-up.
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
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.
Session forks can retain task-part references to the source session's subagent sessions. Continuing a copied task then runs the original child session, so activity, permission prompts, and state can leak between the source and fork. This affects every editor flow using the generated SDK fork endpoint, including the sidebar, Agent Manager LOCAL sessions, Agent Manager worktrees, and Continue in Worktree.
The isolation behavior originally introduced in #8956 regressed in two migrations:
daaa2e5911introduced the Effect HttpApi lifecycle handler and called the rawSession.Service.fork()operation directly. That bypassed the Kilo wrapper responsible for cloning and remapping task child sessions.e4c9b4363econverted the remapper to Effect services but lost the graph-wide source-to-copy map, its root seed, and the cyclic-session regression coverage. Self-references and cycles were no longer safely remapped.This restores isolation at the shared server boundary used by editor clients. The HTTP fork wrapper now remaps task child-session references after creating the root fork, while direct CLI forks retain the same behavior. A single graph-wide map is seeded with the source and copied roots, reused through recursive child forks, and used to rewrite task metadata. This makes each referenced subagent independent, deduplicates repeated references, and terminates self-referential or cyclic graphs.
Regression coverage now exercises the generated SDK against the real HTTP route used by Agent Manager, and restores nested, self-referential, and cyclic session graph cases. A patch changeset records the restored user-facing behavior.