Skip to content

[enhancement] Add dynamic model switching during task execution #28

@github-actions

Description

@github-actions

Background

The Copilot SDK v0.1.30 (released March 3, 2026) introduces session.setModel() for mid-session model switching, implemented by Patrick Nikoletich in commit bd98e3a.

This new API allows changing the model mid-conversation without destroying the session, preserving conversation history while taking advantage of different model capabilities.

Proposal

Implement dynamic model selection during the Execute phase to optimize cost and performance:

  1. Add model configuration to Task schema - Allow users to specify which model to use per task (e.g., gpt-4.1 for complex planning, gpt-5-mini for simple file operations)

  2. Implement model switching in executor.ts - Before dispatching each task, call session.setModel(task.model) to switch to the appropriate model for that specific task

  3. Add UI controls in Refine screen - Allow users to assign models to tasks during the refinement phase (similar to how dependencies are edited)

  4. Smart defaults - Automatically suggest models based on task complexity:

    • Complex tasks (with many dependencies, long descriptions) → gpt-4.1 or claude-sonnet-4
    • Simple tasks (single file edits, basic operations) → gpt-5-mini
    • Parallel batch optimization → use faster models for independent simple tasks

Benefit

  • Cost optimization: Use cheaper/faster models for simple tasks, reserve expensive models for complex planning
  • Performance improvement: Faster model = quicker execution for straightforward tasks
  • Flexibility: Users can fine-tune the model selection strategy for their specific workload
  • Session preservation: No need to recreate sessions when switching models, maintains conversation context

Acceptance Criteria

  • Task model in src/models/plan.ts includes optional model?: string field
  • src/services/executor.ts calls session.setModel() before dispatching tasks with custom models
  • Task editor in src/screens/refine.tsx allows selecting model from dropdown
  • Default model selection logic suggests appropriate models based on task complexity heuristics
  • Session events display model_change events in the Execute screen
  • Tests verify model switching behavior in src/services/executor.test.ts
  • Documentation in README explains model selection strategy

AI generated by Weekly Enhancement Suggestions

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions