[BUG] [BUG] Switching from Opus 4.7 1M to Sonnet mid-session (~700k tokens) breaks session completely — no recovery possible

Resolved 💬 3 comments Opened Apr 24, 2026 by cv-alvarez Closed May 29, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I was working in a session using Opus 4.7 with 1M context window, with approximately 700k tokens accumulated. I switched models to Sonnet mid-session. After switching, the session became completely broken:

Repeated API Error: Prompt is too long
This conversation has reached its length limit. Start a new session to continue.
Usage limit reached displayed in the input bar
Could not type, delete, or press Enter
/compact was not triggered automatically
The only interactive element was the Create PR button

The session eventually unblocked after clicking Create PR multiple times, but this was not a reliable or intentional fix.
Expected behavior: Switching models mid-session should either trigger /compact automatically or warn the user that the accumulated context exceeds the new model's limit. The session should never become fully locked with no recovery path.

Environment:

Plan: Claude Max 5x
Model: Opus 4.7 1M → switched to Sonnet 4.6
Interface: Claude Code Desktop App

What Should Happen?

When switching models mid-session, Claude Code should detect that the accumulated context exceeds the new model's token limit and either:

Automatically trigger /compact to reduce the context before switching
Warn the user that the current context (~700k tokens) exceeds the new model's limit and ask for confirmation before switching
If the switch already happened and the limit is exceeded, offer a recovery option (like a forced /compact) instead of locking the session completely with no way out

The session should never reach a fully locked state where the user cannot type, delete, or execute any command.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce:

Start a long session with Opus 4.7 1M context
Accumulate ~700k tokens
Switch to Sonnet mid-session
Session locks completely

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.110 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗