diff --git a/agent/model_metadata.py b/agent/model_metadata.py index 24ebf34657..01204e8aa6 100644 --- a/agent/model_metadata.py +++ b/agent/model_metadata.py @@ -164,6 +164,8 @@ _URL_TO_PROVIDER: Dict[str, str] = { "openrouter.ai": "openrouter", "inference-api.nousresearch.com": "nous", "api.deepseek.com": "deepseek", + "api.githubcopilot.com": "copilot", + "models.github.ai": "copilot", } @@ -788,8 +790,12 @@ def get_model_context_length( if cached is not None: return cached - # 2. Active endpoint metadata for explicit custom routes - if _is_custom_endpoint(base_url): + # 2. Active endpoint metadata for truly custom/unknown endpoints. + # Known providers (Copilot, OpenAI, Anthropic, etc.) skip this — their + # /models endpoint may report a provider-imposed limit (e.g. Copilot + # returns 128k) instead of the model's full context (400k). models.dev + # has the correct per-provider values and is checked at step 5+. + if _is_custom_endpoint(base_url) and not _is_known_provider_base_url(base_url): endpoint_metadata = fetch_endpoint_model_metadata(base_url, api_key=api_key) matched = endpoint_metadata.get(model) if not matched: