claude-code - 💡(How to fix) Fix [BUG] Model provider switch resets conversation context and memory state [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#46420Fetched 2026-04-11 06:20:46
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Root Cause

Root Cause Hypothesis

Fix Action

Workaround

Users must:

  1. Write all critical findings to MEMORY.md before any model switch
  2. Use /clear + explicit command before starting new work in a different model context
  3. Reference files rather than conversation history for continuity
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this has not been reported yet
  • This is a single bug report
  • I am using the latest version of Claude Code

What's Wrong?

Switching between model providers (e.g., from default provider to a custom ANTHROPIC_BASE_URL endpoint, or switching between two different configured models) causes complete loss of conversation context, memory state, and in-progress understanding.

This happens even when:

  • The session is within normal context window limits
  • No /clear or explicit reset command was issued
  • Both models are configured with the same API credentials

Reproduction

  1. Start a conversation with Model A (default provider or configured endpoint)
  2. Establish context, load project memory files, develop an understanding of the codebase
  3. Switch to Model B (different provider or different model on the same provider)
  4. All context is lost — the model starts "fresh" with no memory of prior conversation

Observed Behavior

The following patterns are lost across a model switch:

  • Memory files: .claude/learnings/ and MEMORY.md entries from the session are not recalled
  • Conversation history: Previous messages are not visible in the new model's context
  • In-progress understanding: Key findings discovered earlier in the session are forgotten
  • Tool use memory: The new model does not know what tools have been used or their results

This forces users to write critical findings to memory files before any model switch — which is a fragile workaround, not a solution.

Expected Behavior

Switching models within the same session should preserve:

  • Access to memory files (they were already loaded by the system)
  • Conversation context (same session ID, same conversation history)
  • In-progress work (same state, just a different model processing it)

Root Cause Hypothesis

Model providers maintain isolated conversation states. Each new model session starts fresh unless explicitly handed off. When Claude Code switches providers mid-session, the context handoff does not occur.

Workaround

Users must:

  1. Write all critical findings to MEMORY.md before any model switch
  2. Use /clear + explicit command before starting new work in a different model context
  3. Reference files rather than conversation history for continuity

Impact

  • Broken multi-provider workflows: Teams using different providers for cost/performance optimization lose all context when routing between them
  • Forced write-before-switch pattern: Requires discipline that breaks natural conversation flow
  • Context loss on model rotation: Even rotating between the same model family on the same provider causes context loss

Suggested Labels

area:providers, area:core, bug

extent analysis

TL;DR

Implementing a context handoff mechanism between model providers could resolve the issue of lost conversation context when switching between models.

Guidance

  • Investigate the feasibility of implementing a context handoff mechanism that preserves conversation state, memory files, and in-progress understanding when switching between model providers.
  • Verify that the issue is indeed caused by isolated conversation states maintained by each model provider, as hypothesized in the root cause analysis.
  • Consider developing a temporary workaround that automatically writes critical findings to MEMORY.md before switching models, to mitigate the impact of context loss.
  • Explore the possibility of using a shared storage mechanism for conversation context, allowing different model providers to access and continue from the same state.

Example

No specific code example can be provided without further information on the implementation details of Claude Code and its model providers.

Notes

The solution may require significant changes to the architecture of Claude Code and its interaction with model providers, and may involve cooperation from the providers themselves to implement a context handoff mechanism.

Recommendation

Apply a workaround, such as automatically writing critical findings to MEMORY.md before switching models, until a more permanent solution can be implemented, as this will help mitigate the impact of context loss on user workflows.

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