From 5f9186d1f9bb38edfa6e2108d1ef2f9f42d4ecfc Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Tue, 27 Oct 2026 15:56:17 +0800 Subject: [PATCH] fix(github-copilot): adapt main's new session and router code to the merged branch --- litellm/router.py | 6 +++--- .../_support/copilot_session_prometheus_worker.py | 14 +++++++++----- .../test_prometheus_invalid_key_filtering.py | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index adb1a116e64..4d817de1c30 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -4797,11 +4797,11 @@ class Router: - Merges tools from deployment with request (proxy-configured tools + request tools). - On a fallback hop, drops the encrypted reasoning this deployment cannot decrypt, keeping its summary. """ - deployment_litellm_params: Final = cast( # cast-ok: a dict or LiteLLM_Params, both answer get + deployment_param_lookup: Final = cast( # cast-ok: a dict or LiteLLM_Params, both answer get "DeploymentParamLookup", deployment["litellm_params"] ) caller_kwargs: Final = cast("Mapping[str, object]", kwargs) # cast-ok: router call kwargs are a str-keyed dict - caller_endpoint_keys: Final = github_copilot_caller_endpoint_keys(deployment_litellm_params, caller_kwargs) + caller_endpoint_keys: Final = github_copilot_caller_endpoint_keys(deployment_param_lookup, caller_kwargs) router_defaults: Final = cast( # cast-ok: router default params are a str-keyed dict "Mapping[str, object]", self.default_litellm_params ) @@ -4810,7 +4810,7 @@ class Router: value for value in ( caller_kwargs.get("drop_params"), - deployment_litellm_params.get("drop_params"), + deployment_param_lookup.get("drop_params"), router_defaults.get("drop_params"), ) if value is not None diff --git a/tests/integration/_support/copilot_session_prometheus_worker.py b/tests/integration/_support/copilot_session_prometheus_worker.py index a6b2c5d4692..279807f3170 100644 --- a/tests/integration/_support/copilot_session_prometheus_worker.py +++ b/tests/integration/_support/copilot_session_prometheus_worker.py @@ -7,19 +7,22 @@ from __future__ import annotations import asyncio import json +import os import subprocess import sys -from itertools import chain from dataclasses import dataclass +from itertools import chain from typing import Final -import litellm import openai -from litellm.integrations.prometheus import PrometheusLogger -from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession from prometheus_client import REGISTRY from pydantic import TypeAdapter +import litellm +from litellm.integrations.prometheus import PrometheusLogger +from litellm.llms.github_copilot.github_host import github_host_endpoints +from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession + COPILOT_DEPLOYMENT: Final = "copilot-per-user-deployment" OPERATOR_DEPLOYMENT: Final = "operator-key-deployment" CALLER_SESSION_TOKEN: Final = "caller-copilot-session-token" @@ -77,6 +80,7 @@ _REPORT: Final = TypeAdapter(WorkerReport) def run_copilot_session_worker(api_base: str) -> WorkerReport: completed: Final = subprocess.run( (sys.executable, "-P", __file__, api_base), + env={**os.environ, "GITHUB_COPILOT_API_BASE": api_base}, capture_output=True, text=True, timeout=WORKER_TIMEOUT_SECONDS, @@ -146,7 +150,7 @@ async def _direct_attempt(api_base: str) -> Outcome: async def main(api_base: str) -> None: litellm.callbacks = [PrometheusLogger()] # test-quality-ok: this worker process exits right after the report - session: Final = GithubCopilotUserSession(token=CALLER_SESSION_TOKEN, api_base=api_base) + session: Final = GithubCopilotUserSession(token=CALLER_SESSION_TOKEN, endpoints=github_host_endpoints("github.com")) router: Final = _router(api_base) outcomes: Final = ( await _attempt(router, COPILOT_DEPLOYMENT, github_copilot_user_session=session), diff --git a/tests/unit/integrations/test_prometheus_invalid_key_filtering.py b/tests/unit/integrations/test_prometheus_invalid_key_filtering.py index 453fd28636d..8c5f22c5fd0 100644 --- a/tests/unit/integrations/test_prometheus_invalid_key_filtering.py +++ b/tests/unit/integrations/test_prometheus_invalid_key_filtering.py @@ -19,6 +19,7 @@ from prometheus_client.samples import Sample import litellm from litellm.constants import LITELLM_LOGGING_NO_UPSTREAM_LLM_CALL from litellm.integrations.prometheus import PrometheusLogger +from litellm.llms.github_copilot.github_host import github_host_endpoints from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession from litellm.proxy._types import ProxyErrorTypes, ProxyException, UserAPIKeyAuth @@ -223,7 +224,7 @@ class TestSkipMetricsValidation: { "litellm_params": { "github_copilot_user_session": GithubCopilotUserSession( - token="caller-session-token", api_base="https://api.githubcopilot.com" + token="caller-session-token", endpoints=github_host_endpoints("github.com") ) } },