Skip to content

Support Opus 4.6 extended context window (1M tokens)#27

Merged
himattm merged 5 commits intomainfrom
claude/support-opus-extended-context-gdHxr
Mar 14, 2026
Merged

Support Opus 4.6 extended context window (1M tokens)#27
himattm merged 5 commits intomainfrom
claude/support-opus-extended-context-gdHxr

Conversation

@himattm
Copy link
Owner

@himattm himattm commented Mar 14, 2026

  • 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

claude added 2 commits March 13, 2026 20:45
- 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
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • Context Window Display: Implemented dynamic display of context window size in the model name, such as "Opus 4.6 (1M)", to provide immediate visibility to users.
  • Model-Aware Default Context: Introduced a model-aware default context window, setting 1M tokens for Opus 4.6 models and a fallback of 200k for others when the context window is not explicitly provided.
  • Legacy Context Calculation Fix: Corrected the legacy context percentage calculation to properly handle 1M token context windows, ensuring accurate usage reporting across different model capacities.

🧠 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
  • internal/statusline/statusline.go
    • Modified renderModel to append formatted context window size to the model display name.
    • Added defaultContextWindow function to provide a fallback context window size.
    • Added formatContextWindowSize function to format token counts into human-readable "M" or "k" units.
    • Updated calculateContextPctLegacy to use the new defaultContextWindow function.
  • internal/statusline/statusline_test.go
    • Added unit tests for defaultContextWindow and formatContextWindowSize.
    • Included new tests for renderModel to verify context window display and fallback behavior.
    • Added a test for calculateContextPctLegacy to confirm correct calculation with a 1M context window.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

high

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)

high

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)

medium

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)
	}
}

claude added 2 commits March 14, 2026 04:16
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
@himattm himattm merged commit c7631b1 into main Mar 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants