fix(copilot): wire live /models max_prompt_tokens into context-window resolver#12840
Closed
difujia wants to merge 1 commit into
Closed
fix(copilot): wire live /models max_prompt_tokens into context-window resolver#12840difujia wants to merge 1 commit into
difujia wants to merge 1 commit into
Conversation
… resolver The Copilot provider resolved context windows via models.dev static data, which does not include account-specific models (e.g. claude-opus-4.6-1m with 1M context). This adds the live Copilot /models API as a higher- priority source for copilot/copilot-acp/github-copilot providers. New helper get_copilot_model_context() in hermes_cli/models.py extracts capabilities.limits.max_prompt_tokens from the cached catalog. Results are cached in-process for 1 hour. In agent/model_metadata.py, step 5a queries the live API before falling through to models.dev (step 5b). This ensures account-specific models get correct context windows while standard models still have a fallback. Part 1 of NousResearch#7731. Refs: NousResearch#7272
13 tasks
This was referenced Apr 24, 2026
Contributor
Author
|
Cherry-picked into main via 7632919. Thanks! |
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.
Addresses part 1 of #7731, as scoped by @konsisumer in #7731 (comment).
Problem
The Copilot provider resolves context windows via models.dev static data, which does not include account-specific models (e.g.
claude-opus-4.6-1mwith 1M context). These models fall through to the 128K default.Solution
Wire
capabilities.limits.max_prompt_tokensfrom the live Copilot/modelsAPI into the context-window resolver as a higher-priority source than models.dev.Changes:
hermes_cli/models.py: Newget_copilot_model_context(model_id)helper that extractsmax_prompt_tokensfrom the cached catalog. Results cached in-process for 1 hour.agent/model_metadata.py: New step 5a inget_model_context_length()queries the live API forcopilot/copilot-acp/github-copilotproviders before falling through to models.dev (step 5b).tests/hermes_cli/test_copilot_context.py: 11 tests covering cache behavior, edge cases (missing limits, zero values, empty catalog), and integration withget_model_context_length().Design notes
/modelswas previously skipped: it returns provider-imposed limits (e.g. 128K) rather than native model context (e.g. 400K). This PR intentionally uses the provider-enforced limit as the effective context window for Copilot, since that is what users can actually use. For models not in models.dev (likeclaude-opus-4.6-1m), this is the only data source.