Skip to content

fix(claude): avoid resetting the Claude model on every turn#1466

Merged
juliusmarminge merged 1 commit intopingdotgg:mainfrom
harshit97:fix/claude-model-reset-chatter
Mar 27, 2026
Merged

fix(claude): avoid resetting the Claude model on every turn#1466
juliusmarminge merged 1 commit intopingdotgg:mainfrom
harshit97:fix/claude-model-reset-chatter

Conversation

@harshit97
Copy link
Copy Markdown
Contributor

@harshit97 harshit97 commented Mar 27, 2026

Closes #1381

This fixes a Claude adapter edge case where we were effectively re-selecting the same model over and over, which could add unnecessary control-message noise to the turn flow / context.

What changed

  • cache the resolved Claude API model id in session state
  • only call setModel when that resolved id actually changes

Why

For Claude, the raw model slug is not always the final API model id we send through, so the guard needs to compare the resolved value. That keeps us from doing extra model resets when nothing has really changed.

Validation

  • added focused regression coverage for this path and ran the usual checks
  • manual test:
    • sent the same prompt multiple times and confirmed the provider log no longer shows extra /model chatter
    • changed the model manually and confirmed the Claude session still updates correctly

Note

Fix Claude adapter to skip setModel calls when the effective API model is unchanged

Adds a currentApiModelId field to ClaudeSessionContext to track the API model currently applied to the session. In sendTurn, the adapter now compares the resolved API model against currentApiModelId and only calls query.setModel when the model has actually changed, updating currentApiModelId afterward.

Macroscope summarized c7a018b.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5489b6b-eff4-4de1-a9a4-0b9d949685ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 27, 2026
@juliusmarminge juliusmarminge merged commit fb72607 into pingdotgg:main Mar 27, 2026
11 checks passed
aaditagrawal pushed a commit to aaditagrawal/t3code that referenced this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude context polluted with model change message every turn on web

2 participants