Support Opus 4.6 extended context window (1M tokens)#27
Conversation
- Add model-aware default context window: 1M for 4.6 models, 200k for others - Display context window size in model name (e.g., "Opus 4.6 (1M)") - Fix legacy context percentage calculation for 1M context windows https://claude.ai/code/session_017ZBnMn7zD8yxssJUsGNLfF
Extended context (1M tokens) cannot be reliably detected from the model name alone — a 4.6 model may or may not have extended context enabled. The fallback now always returns 200k; the correct size is only used when Claude Code provides context_window_size in its payload. https://claude.ai/code/session_017ZBnMn7zD8yxssJUsGNLfF
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 enhances the application's ability to display and manage large language model context windows, particularly for models like Opus 4.6 with 1M token capacity. It ensures that users are aware of the active context window size and that context usage calculations remain accurate across different model capacities, improving the user experience and reliability when working with advanced LLMs. 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 adds support for larger context windows by displaying the window size and using it in calculations. My review focuses on fully implementing the model-aware context window logic as described in the pull request description and improving the readability of a new helper function. I've provided specific code suggestions to address these points. After applying the changes, some of the new tests will also need to be updated.
I am having trouble creating individual review comments. Click here to see my feedback.
internal/statusline/statusline.go (329-344)
The PR description states "Add model-aware default context window: 1M for 4.6 models, 200k for others", but this implementation always returns 200k. To implement this feature, defaultContextWindow should accept the model name. The function's comment is also inconsistent with the PR's goal.
func (sl *StatusLine) renderModel() string {
name := sl.input.Model.DisplayName
windowSize := sl.input.Context.ContextWindow
if windowSize == 0 {
windowSize = defaultContextWindow(name)
}
suffix := formatContextWindowSize(windowSize)
return colors.Wrap(colors.Magenta, name+" "+suffix)
}
// defaultContextWindow returns a fallback context window size when Claude Code
// does not provide context_window_size. It returns 1M for models with "4.6"
// in their name, and 200k for others.
func defaultContextWindow(modelName string) int {
if strings.Contains(modelName, "4.6") {
return 1000000
}
return 200000
}internal/statusline/statusline.go (391)
To make the default context window model-aware (as suggested in another comment), this call to defaultContextWindow needs to be updated to pass the model name.
windowSize = defaultContextWindow(sl.input.Model.DisplayName)internal/statusline/statusline.go (347-355)
The switch statement in this function has a redundant case. The second case (case tokens >= 1000 && tokens%1000 == 0) and the default case have identical logic. This can be simplified for better readability and maintainability.
func formatContextWindowSize(tokens int) string {
switch {
case tokens >= 1000000 && tokens%1000000 == 0:
return fmt.Sprintf("(%dM)", tokens/1000000)
default:
return fmt.Sprintf("(%dk)", tokens/1000)
}
}Previously only handled exact multiples of 1M and integer multiples of 1k. Now correctly formats fractional millions (1.5M), fractional thousands (1.5k), and sub-thousand values (500). https://claude.ai/code/session_017ZBnMn7zD8yxssJUsGNLfF
Uh oh!
There was an error while loading. Please reload this page.