Skip to content

fix: agent-manager model sync on config change#10094

Merged
marius-kilocode merged 6 commits into
Kilo-Org:mainfrom
IamCoder18:fix/agent-manager-model-sync
Jun 9, 2026
Merged

fix: agent-manager model sync on config change#10094
marius-kilocode merged 6 commits into
Kilo-Org:mainfrom
IamCoder18:fix/agent-manager-model-sync

Conversation

@IamCoder18

Copy link
Copy Markdown
Contributor

Context

When a user changes the model in Settings, the sidebar chat updates correctly, but the Agent Manager continues using the old model. This happens because:

  1. Agent Manager sessions store sessionOverrides that short-circuit config-based model resolution
  2. NewWorktreeDialog captures session.selected() at dialog open time, including stale overrides

Closes #9349

Implementation

NewWorktreeDialog.tsx:

  • Changed session.selected() to session.configModel() for model initialization
  • This captures the config-based model (global + per-agent mode) without session-level overrides

session.tsx:

  • Exposed configModel() function in SessionContextValue interface and context value
  • Added createEffect that watches getGlobalModel() and clears sessionOverrides when the config model changes
  • The effect only clears overrides that matched the OLD config model (likely default values), preserving intentional user overrides

The reactive effect uses SolidJS signals to track the previous config model and compares it with the current value. When they differ, overrides matching the old config are removed via produce() for batched store updates.

Screenshots

Before

before.mp4

After

after.mp4

How to Test

  1. Open the Agent Manager and create a worktree (observe the model in the dialog)
  2. Change the model in Settings (Sidebar → Settings → Model)
  3. Open the New Worktree dialog again - it should now show the newly selected model
  4. Create a new worktree - it should use the new model, not the old one
  5. Existing worktree sessions should also reflect the new model (overrides cleared if they matched old config)

Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx Outdated
Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx Outdated
@kilo-code-bot

kilo-code-bot Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Previous Issues (all resolved)

All issues raised across this review cycle have been addressed:

File Line Issue Status
packages/kilo-vscode/webview-ui/src/context/session.tsx 782 lastConfigModel() read inside effect causing spurious double-run ✅ Fixed — untrack(() => lastConfigModel()) used
packages/kilo-vscode/webview-ui/src/context/session.tsx 808 Guard skipped cleanup when config model transitioned to null ✅ Fixed — else branch handles null transition
packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx 124, 444 overridden memo and reset button still used session.selected() instead of session.configModel() ✅ Fixed — both changed to session.configModel() in commit a8f3a69
Files Reviewed (3 files)
  • packages/kilo-vscode/webview-ui/src/context/session.tsx — 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx — 0 issues
  • .changeset/agent-manager-model-sync.md — 0 issues

Reviewed by claude-4.6-sonnet-20260217 · 331,056 tokens

Review guidance: REVIEW.md from base branch main

IamCoder18 added 2 commits May 9, 2026 11:12
…e overrides on config change

- Replace session.selected() with session.configModel() in NewWorktreeDialog to reflect the configured model rather than the selected session model.
- Add configModel to SessionContext and implement an effect that clears session overrides matching the old config model when the global config model changes, ensuring sessions pick up the new config model.
@IamCoder18 IamCoder18 force-pushed the fix/agent-manager-model-sync branch from 29d3310 to e1e75a3 Compare May 9, 2026 17:30
@marius-kilocode

Copy link
Copy Markdown
Collaborator

@IamCoder18 my bot sais this fix doesn't work for the new worktree modal? (cmd shift n), is this true?

NewWorktreeDialog.tsx:88 initializes from session.configModel().
But NewWorktreeDialog.tsx:122-127 still compares against session.selected().
And NewWorktreeDialog.tsx:444 resets back to session.selected().

@IamCoder18

Copy link
Copy Markdown
Contributor Author

@IamCoder18 my bot sais this fix doesn't work for the new worktree modal? (cmd shift n), is this true?

NewWorktreeDialog.tsx:88 initializes from session.configModel(). But NewWorktreeDialog.tsx:122-127 still compares against session.selected(). And NewWorktreeDialog.tsx:444 resets back to session.selected().

You're right. I had only tested local sessions, not sessions in worktrees or the New Worktree modal. I'll fix this later today.

Use session.configModel() instead of session.selected() in NewWorktreeDialog
so the overridden comparison (line 124) and the reset handler (line 444) both
use the config-based model. This prevents stale overridden states from
session.selected() from leaking into the worktree dialog's override detection
and reset behaviour.

Partially fixes Kilo-Org#9349.
@IamCoder18

IamCoder18 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@IamCoder18 my bot sais this fix doesn't work for the new worktree modal? (cmd shift n), is this true?

NewWorktreeDialog.tsx:88 initializes from session.configModel(). But NewWorktreeDialog.tsx:122-127 still compares against session.selected(). And NewWorktreeDialog.tsx:444 resets back to session.selected().

@marius-kilocode Fixed!

2026-05-22.17-18-16.mp4

@marius-kilocode marius-kilocode merged commit d881bfc into Kilo-Org:main Jun 9, 2026
11 checks passed
@marius-kilocode

Copy link
Copy Markdown
Collaborator

Looks good @IamCoder18, thanks for the fix!

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.

Changing model in Settings doesn't update model on Agent Manager

2 participants