Skip to content

fix(cli): preserve forked session variants#12175

Merged
marius-kilocode merged 8 commits into
mainfrom
investigate-worktree-variant-inheritance
Jul 14, 2026
Merged

fix(cli): preserve forked session variants#12175
marius-kilocode merged 8 commits into
mainfrom
investigate-worktree-variant-inheritance

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

Forked sessions copied their transcript but did not preserve the selected model configuration at the fork point. Agent Manager then records a synthetic noReply handoff without a model or variant. That handoff resolved the model but omitted its reasoning variant, so it produced a user message with no variant and asynchronously switched the forked session to the default variant before the next user prompt.

This affects Agent Manager session forks, including Fork session into a selected worktree or the local workspace. It also affects the sidebar's Continue in Worktree action, which creates a worktree and invokes the same fork-plus-handoff path. Ordinary sidebar follow-up prompts do not fork a session or record this handoff, so they are unaffected.

Behavior

For a full-session fork, retain the source session model and selected reasoning variant. For a historical fork at a message point, derive the model and variant from the latest retained user message instead of leaking a later source-session selection into the fork.

When a prompt has no explicit model and no agent-selected model, reuse the variant stored on that forked session when recording the synthetic handoff. Explicit prompt variants remain authoritative, and agent-selected models continue to use their existing model and variant behavior.

This keeps the selected reasoning level stable through the fork and its context handoff, while allowing later explicit model or variant selections to replace it.

Comment thread packages/opencode/src/session/session.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • packages/opencode/test/session/prompt.test.ts
Previous Review Summaries (2 snapshots, latest commit 0062801)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 0062801)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/session/session.ts
  • packages/opencode/test/session/session.test.ts

Previous review (commit 0a388de)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/session/session.ts 787 Historical forks inherit the source session's current model and variant even when those were selected after the requested fork point.
Files Reviewed (5 files)
  • .changeset/fork-session-variant.md - 0 issues
  • packages/opencode/src/session/prompt.ts - 0 issues
  • packages/opencode/src/session/session.ts - 1 issue
  • packages/opencode/test/session/prompt.test.ts - 0 issues
  • packages/opencode/test/session/session.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by gpt-5.6-sol · Input: 58.5K · Output: 3.2K · Cached: 178.4K

Review guidance: REVIEW.md from base branch main

AlexOcculate pushed a commit to AlexOcculate/kilocode that referenced this pull request Jul 14, 2026
@marius-kilocode
marius-kilocode merged commit e2b609e into main Jul 14, 2026
29 checks passed
@marius-kilocode
marius-kilocode deleted the investigate-worktree-variant-inheritance branch July 14, 2026 05:18
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.

2 participants