claude-code - 💡(How to fix) Fix [FEATURE] Feature: Auto model-switching with user approval (Sonnet → Opus on complexity) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48263Fetched 2026-04-16 07:04:48
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1unlabeled ×1
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Summary

Claude Code currently runs on a single fixed model per session. I'd like a feature where Claude Code starts with Sonnet by default and automatically detects when a task is complex enough to warrant Opus — then asks the user for permission before switching.

Proposed Behavior

  1. Default model: claude-sonnet-4-6 (fast, cost-effective)
  2. Complexity detection: Claude Code internally estimates whether the current task (e.g. deep algorithmic design, multi-file refactoring, complex debugging) exceeds Sonnet's optimal range
  3. Permission prompt: Before switching, show a confirmation like:

    "This task may benefit from Opus. Switch model? (costs ~5× more) [y/N]"

  4. Switch: If approved, continue the task with claude-opus-4-6
  5. Optional auto-revert: Switch back to Sonnet after the complex task completes

Motivation

  • Gemini CLI already does something similar — lightweight model by default, escalates when needed
  • Most tasks don't need Opus; paying for it always is wasteful
  • Users want control over cost without manually running /model before every hard task

Configuration (suggested)

{
  "defaultModel": "claude-sonnet-4-6",
  "autoUpgrade": {
    "enabled": true,
    "upgradeModel": "claude-opus-4-6",
    "requireConfirmation": true
  }
}

Alternatives Considered

- Manual /model switching — works but requires the user to predict complexity upfront
- Always use Opus — too expensive for routine tasks

### Proposed Solution

## Proposed Solution

Introduce a lightweight **complexity classifier** that runs before each tool-use cycle:

- Heuristics: task involves >3 files, algorithmic design, multi-step reasoning, or the user prompt explicitly asks for architecture/planning
- When complexity score exceeds a threshold, Claude Code pauses and prompts:
  > "⚡ This task looks complex. Switch to Opus for better results? (costs ~5× more) [y/N]"
- If the user approves, the current session context is carried over and the request is re-sent with `claude-opus-4-6`
- After the response, revert to Sonnet automatically (or keep Opus for the session — user's choice)

This can be implemented as a client-side routing layer in Claude Code without changes to the Claude API itself.

### Alternative Solutions

_No response_

### Priority

Critical - Blocking my work

### Feature Category

CLI commands and flags

### Use Case Example

_No response_

### Additional Context

_No response_

extent analysis

TL;DR

Implement a complexity classifier to automatically detect complex tasks and prompt the user to switch from the default Sonnet model to Opus, ensuring cost-effective and efficient task completion.

Guidance

  • Introduce a configuration option to enable or disable the auto-upgrade feature, allowing users to control the behavior based on their needs and cost considerations.
  • Develop a complexity classifier that assesses task complexity based on heuristics such as the number of files involved, algorithmic design, and multi-step reasoning, and prompts the user to switch to Opus when the complexity score exceeds a threshold.
  • Implement a client-side routing layer in Claude Code to handle the model switching without requiring changes to the Claude API.
  • Consider adding an option for the user to choose whether to revert to Sonnet automatically after the complex task completes or keep using Opus for the session.

Example

{
  "defaultModel": "claude-sonnet-4-6",
  "autoUpgrade": {
    "enabled": true,
    "upgradeModel": "claude-opus-4-6",
    "requireConfirmation": true,
    "revertAfterTask": true // optional
  }
}

Notes

The proposed solution requires careful consideration of the complexity classifier's heuristics and threshold to ensure accurate detection of complex tasks and minimize unnecessary prompts. Additionally, the cost implications of switching to Opus should be clearly communicated to the user.

Recommendation

Apply the proposed solution with a complexity classifier and user confirmation prompt, as it provides a balanced approach to cost-effectiveness and task efficiency. This approach allows users to control costs while still benefiting from the more powerful Opus model when needed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING