claude-code - 💡(How to fix) Fix Bug: injected system context hardcodes model name, ignores --model flag override [2 comments, 3 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#50714Fetched 2026-04-20 12:15:06
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2

When launching Claude Code with --model claude-opus-4-7, the CLI correctly displays the model as Opus 4.7 in the welcome banner. However, the system prompt injected into the model's context hardcodes \"You are powered by the model named Sonnet 4.6. The exact model ID is claude-sonnet-4-6.\" — causing the model to incorrectly self-identify when asked about its version.

Root Cause

Root Cause (Hypothesis)

RAW_BUFFERClick to expand / collapse

Summary

When launching Claude Code with --model claude-opus-4-7, the CLI correctly displays the model as Opus 4.7 in the welcome banner. However, the system prompt injected into the model's context hardcodes \"You are powered by the model named Sonnet 4.6. The exact model ID is claude-sonnet-4-6.\" — causing the model to incorrectly self-identify when asked about its version.

Steps to Reproduce

  1. Run: claude --model claude-opus-4-7
  2. CLI shows: Opus 4.7 · Claude Pro and Welcome to Opus 4.7 xhigh!
  3. Ask the model: which model do you use?
  4. Model responds: Sonnet 4.6 (wrong)

Expected Behavior

The injected system context should reflect the actual model being used. When --model claude-opus-4-7 is passed, the system prompt should say "You are powered by the model named Opus 4.7. The exact model ID is claude-opus-4-7."

Actual Behavior

The system prompt contains a hardcoded model name (claude-sonnet-4-6) that is not updated when --model overrides the default. The model self-identifies incorrectly.

Environment

  • Claude Code version: 2.1.114
  • Model flag used: --model claude-opus-4-7
  • Platform: Windows 11 (PowerShell)

Root Cause (Hypothesis)

The harness that constructs the system prompt appears to use a static string for the model name rather than dynamically substituting the resolved model ID at runtime.

Impact

  • Model self-reports incorrect version when users ask
  • Any harness logic that branches on the model name string would also behave incorrectly

extent analysis

TL;DR

Update the system prompt to dynamically substitute the resolved model ID at runtime to reflect the actual model being used.

Guidance

  • Verify that the --model flag is correctly overriding the default model in the CLI by checking the welcome banner and model ID.
  • Investigate the harness code that constructs the system prompt to identify where the static string for the model name is being used.
  • Consider modifying the harness to use a dynamic string substitution mechanism to insert the resolved model ID into the system prompt.
  • Test the updated harness with different model flags to ensure the system prompt accurately reflects the actual model being used.

Example

# Pseudo-code example of dynamic string substitution
model_id = resolve_model_id(flag_value)
system_prompt = f"You are powered by the model named {model_id}. The exact model ID is {model_id}."

Notes

The exact implementation details of the harness and system prompt construction are not provided, so the guidance is focused on identifying and addressing the root cause of the issue.

Recommendation

Apply a workaround by modifying the harness to use dynamic string substitution for the model name, as this will allow the system prompt to accurately reflect the actual model being used.

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