[FEATURE] Persistent session context across model/provider switches within the same session

Resolved 💬 3 comments Opened Apr 10, 2026 by Fearvox Closed May 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this has not been reported yet
  • [x] This is a single feature request
  • [x] I am using the latest version of Claude Code

Summary

When a user switches models or API providers mid-session (by changing ANTHROPIC_MODEL or ANTHROPIC_BASE_URL mid-conversation), the conversation context and memory state are not preserved across the switch. The new model/provider starts with zero context.

Feature Request

Add a session continuity mechanism that persists context across model/provider switches within the same running CLI session. Specifically:

  1. Memory file state should survive the switch — if .claude/learnings/ or MEMORY.md were loaded before the switch, they should remain accessible after
  2. Conversation history should be transferable — the message history from before the switch should be available to the new model/provider
  3. Optional opt-in via flag--preserve-context-on-switch to enable this behavior; off by default for users who want fresh starts

Why This Matters

Users on multi-provider setups (cost optimization, model routing, A/B testing) cannot switch models mid-session without losing all context. This forces artificial workflow constraints:

  • "Don't switch models until you're done with this task"
  • "Write everything to memory before switching or lose it"

Prior Art

  • Issue #46420 describes the context loss bug this feature would fix
  • The session storage layer already persists state across sessions — this feature would extend that to model switches within a session

Suggested Labels

enhancement, area:core, area:providers

View original on GitHub ↗

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