fix(claude): Replace hardcoded Claude version (cc_version=2.1.63) in the billing-header#2109
fix(claude): Replace hardcoded Claude version (cc_version=2.1.63) in the billing-header#2109lang-911 wants to merge 1 commit intorouter-for-me:mainfrom
cc_version=2.1.63) in the billing-header#2109Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors how the Claude Code version is managed within the application. Instead of hardcoding the version in multiple places, it introduces a centralized configuration field. This change streamlines updates to the Claude Code version, ensuring that components like billing header generation and fallback User-Agent strings consistently reflect the desired version, thereby improving maintainability and reducing potential discrepancies. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively removes the hardcoded Claude version by introducing a new configuration field claude-header-defaults.version. The changes are well-implemented across the configuration, main logic, and tests. The new version is correctly used for generating the billing header and as a fallback for the User-Agent header. The added tests cover the new functionality, including default behavior, configured behavior, and precedence of a custom User-Agent over the version-derived one. I have one suggestion to improve test clarity by refactoring a test case to have a single responsibility.
| func TestConfiguredClaudeVersionDoesNotOverrideCustomUserAgent(t *testing.T) { | ||
| payload := []byte(`{"system":"You are a helpful assistant.","messages":[{"role":"user","content":"hi"}]}`) | ||
| req := httptest.NewRequest(http.MethodPost, "https://example.com/v1/messages", nil) | ||
| cfg := &config.Config{ | ||
| ClaudeHeaderDefaults: config.ClaudeHeaderDefaults{ | ||
| Version: "2.3.4", | ||
| UserAgent: "claude-cli/custom-build (external, cli)", | ||
| }, | ||
| } | ||
|
|
||
| out := checkSystemInstructionsWithMode(payload, false, cfg) | ||
| billingHeader := gjson.GetBytes(out, "system.0.text").String() | ||
| if !strings.Contains(billingHeader, "cc_version=2.3.4.") { | ||
| t.Fatalf("billing header should use configured Claude version, got %q", billingHeader) | ||
| } | ||
|
|
||
| applyClaudeHeaders(req, nil, "key-123", false, nil, cfg) | ||
|
|
||
| if got := req.Header.Get("User-Agent"); got != "claude-cli/custom-build (external, cli)" { | ||
| t.Fatalf("User-Agent = %q, want %q", got, "claude-cli/custom-build (external, cli)") | ||
| } | ||
| } |
There was a problem hiding this comment.
This test combines two separate concerns: testing checkSystemInstructionsWithMode and applyClaudeHeaders. The check for checkSystemInstructionsWithMode is already covered in TestCheckSystemInstructionsWithMode_UsesConfiguredClaudeVersion, making it redundant here.
To improve clarity and focus, this test should only verify the behavior of applyClaudeHeaders regarding the User-Agent.
Consider renaming the test to something more direct, like TestApplyClaudeHeaders_UsesConfiguredUserAgent, and simplifying its body to focus on that single responsibility.
func TestApplyClaudeHeaders_UsesConfiguredUserAgent(t *testing.T) {
req := httptest.NewRequest(http.MethodPost, "https://example.com/v1/messages", nil)
cfg := &config.Config{
ClaudeHeaderDefaults: config.ClaudeHeaderDefaults{
Version: "2.3.4",
UserAgent: "claude-cli/custom-build (external, cli)",
},
}
applyClaudeHeaders(req, nil, "key-123", false, nil, cfg)
if got := req.Header.Get("User-Agent"); got != "claude-cli/custom-build (external, cli)" {
t.Fatalf("User-Agent = %q, want %q", got, "claude-cli/custom-build (external, cli)")
}
}There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e724b940c4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| func checkSystemInstructions(payload []byte) []byte { | ||
| return checkSystemInstructionsWithMode(payload, false) | ||
| return checkSystemInstructionsWithMode(payload, false, nil) |
There was a problem hiding this comment.
Pass config into count_tokens billing-header generation
checkSystemInstructions now hard-codes nil for cfg, so any caller using this helper (notably the CountTokens flow at body = checkSystemInstructions(body)) will always fall back to defaultClaudeCodeVersion when building cc_version. When claude-header-defaults.version is configured, /v1/messages requests use the configured value but /v1/messages/count_tokens still emits 2.1.63, creating an inconsistent fingerprint and defeating the new configurability in this request path.
Useful? React with 👍 / 👎.
cc_version=2.1.63) in the billing-header
e724b94 to
918f7d5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 918f7d5083
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| func checkSystemInstructions(payload []byte) []byte { | ||
| return checkSystemInstructionsWithMode(payload, false) | ||
| return checkSystemInstructionsWithMode(payload, false, nil) |
There was a problem hiding this comment.
Pass executor config into system-instruction helper
In this commit checkSystemInstructions was updated to call checkSystemInstructionsWithMode(payload, false, nil), and CountTokens still routes /v1/messages/count_tokens through that helper, so claude-header-defaults.version is ignored for billing-header generation on that path. When a custom Claude version is configured, /v1/messages uses it (via applyCloaking/applyClaudeHeaders) but /count_tokens keeps emitting the default cc_version, causing an inconsistent client fingerprint.
Useful? React with 👍 / 👎.
Summary
claude-header-defaults.versionas the Claude Code version sourceUser-AgentTesting