copilot_chat: Return true context window size#47557
Merged
benbrandt merged 3 commits intozed-industries:mainfrom Feb 12, 2026
Merged
copilot_chat: Return true context window size#47557benbrandt merged 3 commits intozed-industries:mainfrom
benbrandt merged 3 commits intozed-industries:mainfrom
Conversation
The `max_token_count()` method was incorrectly returning `max_prompt_tokens` instead of `max_context_window_tokens`. This caused GitHub Copilot Chat models to report incorrect context sizes (e.g., Claude 3.7 reported 90K instead of 200K). This change aligns the behavior with other providers (Anthropic, OpenAI, etc.) that return the full context window size from `max_token_count()`.
Contributor
Author
|
This is a minor fix. @SomeoneToIgnore |
Contributor
Author
|
@yeskunall Added Release Notes. |
benbrandt
reviewed
Feb 12, 2026
…rect token counts
|
For gpt-5.4 show wrong context size: 400k, insted of 1M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix incorrect context size limits for GitHub Copilot Chat models
Fixes #44909
Problem
The agent panel was displaying incorrect token limits for GitHub Copilot models. Users reported that:
Root Cause
The
max_token_count()method incopilot_chat.rswas returningmax_prompt_tokensinstead ofmax_context_window_tokens:GitHub's API returns three different token-related fields:
max_context_window_tokens: The full context window size (e.g., 200K for Claude 3.7)max_prompt_tokens: GitHub's limit for prompt input (e.g., 90K for Claude 3.7)max_output_tokens: Maximum output tokens (e.g., 16K)The
max_token_count()method in theLanguageModeltrait is expected to return the full context window size — this is consistent with all other providers (Anthropic returns 200K for Claude, OpenAI returns 128K for GPT-4o, etc.).Solution
Changed
max_token_count()to returnmax_context_window_tokens:Impact
Testing
Added a new test
test_max_token_count_returns_context_window_not_prompt_tokensthat:max_context_window_tokensandmax_prompt_tokensvaluesAll existing tests continue to pass:
Release Notes: