fix: use transcript model to correct cross-session model contamination#206
Open
AniAggarwal wants to merge 2 commits intosirmalloc:mainfrom
Open
fix: use transcript model to correct cross-session model contamination#206AniAggarwal wants to merge 2 commits intosirmalloc:mainfrom
AniAggarwal wants to merge 2 commits intosirmalloc:mainfrom
Conversation
Read the model from per-session transcript data instead of relying on the global shared state model, which can be contaminated across sessions (anthropics/claude-code#19570, closes sirmalloc#190). When the last transcript entry is a user message (API call in progress), returns null to avoid showing a stale model. Self-corrects once the response arrives.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the model display showing the wrong model when multiple Claude Code sessions are open and one changes models. The root cause is upstream (anthropics/claude-code#19570) — the
modelfield in statusline JSON reads from global shared state instead of per-session state.message.modelon each assistant entry) insidegetTokenMetrics— no extra file readrenderMultipleLineswhen the transcript model differsnullto avoid showing a stale model — self-corrects once the response arrivesTrade-off
Brief window during API calls where cross-session contamination can still show. Acceptable vs permanently displaying the wrong model. This workaround can be removed when Claude Code fixes the upstream bug.
This is a pretty big patch for a bug in upstream, so feel free to reject. I was getting quite annoyed with the status line changing between chats so figured I'd make a PR.
Closes #190
Test plan
tsc --noEmitclean