fix(cli): remap child session references on fork to prevent subagent state leaks - #8956
Merged
Conversation
…state leaks When forking a session, task tool parts referencing child sessions were copied verbatim, causing both original and forked sessions to share the same subagent references. This led to SSE events and permission prompts leaking across sessions in the Agent Manager.
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments: None. Files Reviewed (4 files)
Reviewed by gpt-5.4-20260305 · 400,312 tokens |
Session.fork() already calls remapChildren via the hook, so the explicit recursive call inside remapChildren was double-forking nested descendants.
marius-kilocode
enabled auto-merge (squash)
April 15, 2026 08:59
catrielmuller
suggested changes
Apr 15, 2026
| runPromise((svc) => svc.fork(input)), | ||
| ) | ||
| // kilocode_change start - remap child session references after fork to prevent subagent state leaks | ||
| export const fork = fn(z.object({ sessionID: SessionID.zod, messageID: MessageID.zod.optional() }), async (input) => { |
Contributor
There was a problem hiding this comment.
Please move this custom fork function to packages/opencode/src/kilocode/session/index.ts
and do a single line replace like:
export const fork = kiloSessionFork; // kilocode_change
Collaborator
Author
There was a problem hiding this comment.
Done — moved the custom fork wrapper into packages/opencode/src/kilocode/session/index.ts as kiloSessionFork and changed the shared file to a one-line export const fork = kiloSessionFork // kilocode_change.
catrielmuller
approved these changes
Apr 15, 2026
jliounis
pushed a commit
to jliounis/kilocode
that referenced
this pull request
May 18, 2026
…state leaks (Kilo-Org#8956) * fix(cli): remap child session references on fork to prevent subagent state leaks When forking a session, task tool parts referencing child sessions were copied verbatim, causing both original and forked sessions to share the same subagent references. This led to SSE events and permission prompts leaking across sessions in the Agent Manager. * fix: remove redundant recursive remapChildren call Session.fork() already calls remapChildren via the hook, so the explicit recursive call inside remapChildren was double-forking nested descendants.
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…state leaks (Kilo-Org#8956) * fix(cli): remap child session references on fork to prevent subagent state leaks When forking a session, task tool parts referencing child sessions were copied verbatim, causing both original and forked sessions to share the same subagent references. This led to SSE events and permission prompts leaking across sessions in the Agent Manager. * fix: remove redundant recursive remapChildren call Session.fork() already calls remapChildren via the hook, so the explicit recursive call inside remapChildren was double-forking nested descendants.
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.
Summary
remapChildrennow recursively forks each referenced child session and updates the part metadata to point at the new copies, ensuring complete session isolation