Skip to content

Enable model switching for active sessions#100

Merged
PureWeen merged 4 commits intomainfrom
feature/model-switching
Feb 13, 2026
Merged

Enable model switching for active sessions#100
PureWeen merged 4 commits intomainfrom
feature/model-switching

Conversation

@PureWeen
Copy link
Copy Markdown
Owner

Feature

Enables switching the model on active sessions that already have conversation history. Previously the model dropdown was disabled once any messages were sent.

How it works

ChangeModelAsync disposes the current SDK CopilotSession connection and resumes the same session ID with a new ResumeSessionConfig { Model = newModel }. The session history is preserved server-side — only the backend model changes. This is the same mechanism the Copilot CLI uses internally via its /model slash command.

Changes

  • CopilotService.ChangeModelAsync — new method that reconnects with a different model
  • ExpandedSessionView.razor — dropdown now only disabled while processing (was disabled when history > 0)
  • Dashboard.razorSetExpandedModel calls ChangeModelAsync for active sessions

Guards

  • No-op if already on the requested model
  • Blocks during active processing (IsProcessing)
  • Normalizes model slug before use
  • Preserves working directory on reconnect
  • Error handling with user notification via OnError

Testing

Built and tested: 191 tests pass. Manual testing needed to verify the backend honors the model change on resume.

Add ChangeModelAsync to CopilotService that switches the model of a
running session by disposing the current SDK connection and resuming
with a new ResumeSessionConfig.Model. The session ID and history are
preserved server-side — only the backend model changes.

- Enable the model dropdown for active sessions (was previously
  disabled when history > 0). Now only disabled while processing.
- Update SetExpandedModel in Dashboard to call ChangeModelAsync
  for sessions with history.
- ChangeModelAsync guards: no-op if already on the requested model,
  blocks during processing, normalizes model slug.
Show display names (e.g. 'Claude Opus 4.5') instead of raw slugs in
the inline model selector and info panel, matching the ModelSelector
component used in the sidebar.
- PrettifyModel now replaces all remaining hyphens with spaces (except GPT- prefix)
- Added tests for prettify output, no-duplicate-hyphens, round-trip with NormalizeToSlug
- Fixed in both ExpandedSessionView.razor and ModelSelector.razor
@PureWeen PureWeen merged commit 56ef177 into main Feb 13, 2026
@PureWeen PureWeen deleted the feature/model-switching branch February 22, 2026 00:16
PureWeen added a commit that referenced this pull request Mar 25, 2026
)

## Problem

The orchestrator dispatch prompt led with **"Assign ALL workers that
have relevant work"** which caused models to invent micro-tasks to fill
all 5 workers even for single-item requests. For example, a single PR
re-review would get split into:
- Worker-1: check commits
- Worker-2: do 5-model dispatch  
- Worker-3: grep one file
- Worker-4: build and test
- Worker-5: grep another file

This wastes resources and makes sessions appear stuck (all 5 workers
busy for 10+ minutes on what should be a single-worker job).

## Fix

Flip the emphasis so the **default is ONE worker** and fan-out is the
exception:
- `Assign the MINIMUM number of workers needed`
- `Do NOT split a single task into micro-tasks across workers`
- Only fan out for genuinely independent tasks (e.g., "review PR #100
and PR #200")

## History

- **Mar 10** (`a79f9f40`): Introduced aggressive fan-out with retry loop
- **Mar 12** (`9c58ebf0`): Removed retry loop, added "only relevant"
caveat
- **This PR**: Flips the default from "assign all" to "assign minimum"

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
arisng pushed a commit to arisng/PolyPilot that referenced this pull request Apr 4, 2026
…ureWeen#429)

## Problem

The orchestrator dispatch prompt led with **"Assign ALL workers that
have relevant work"** which caused models to invent micro-tasks to fill
all 5 workers even for single-item requests. For example, a single PR
re-review would get split into:
- Worker-1: check commits
- Worker-2: do 5-model dispatch  
- Worker-3: grep one file
- Worker-4: build and test
- Worker-5: grep another file

This wastes resources and makes sessions appear stuck (all 5 workers
busy for 10+ minutes on what should be a single-worker job).

## Fix

Flip the emphasis so the **default is ONE worker** and fan-out is the
exception:
- `Assign the MINIMUM number of workers needed`
- `Do NOT split a single task into micro-tasks across workers`
- Only fan out for genuinely independent tasks (e.g., "review PR PureWeen#100
and PR PureWeen#200")

## History

- **Mar 10** (`a79f9f40`): Introduced aggressive fan-out with retry loop
- **Mar 12** (`9c58ebf0`): Removed retry loop, added "only relevant"
caveat
- **This PR**: Flips the default from "assign all" to "assign minimum"

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant