From a9bd3a70c992344dba8f4d5c8be565918524d2db Mon Sep 17 00:00:00 2001 From: Tim O'Farrell Date: Sat, 24 Jan 2026 09:53:16 -0700 Subject: [PATCH] Fix V0 Integrations (#12584) --- .../integrations/github/github_manager.py | 3 ++- openhands/llm/llm.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/enterprise/integrations/github/github_manager.py b/enterprise/integrations/github/github_manager.py index a535312894..32ea147dec 100644 --- a/enterprise/integrations/github/github_manager.py +++ b/enterprise/integrations/github/github_manager.py @@ -33,6 +33,7 @@ from server.utils.conversation_callback_utils import register_callback_processor from openhands.core.logger import openhands_logger as logger from openhands.integrations.provider import ProviderToken, ProviderType +from openhands.integrations.service_types import AuthenticationError from openhands.server.types import ( LLMAuthenticationError, MissingSettingsError, @@ -348,7 +349,7 @@ class GithubManager(Manager): msg_info = f'@{user_info.username} please set a valid LLM API key in [OpenHands Cloud]({HOST_URL}) before starting a job.' - except (ExpiredError, SessionExpiredError) as e: + except (AuthenticationError, ExpiredError, SessionExpiredError) as e: logger.warning( f'[GitHub] Session expired for user {user_info.username}: {str(e)}' ) diff --git a/openhands/llm/llm.py b/openhands/llm/llm.py index 10c81b9543..cbbac29c1e 100644 --- a/openhands/llm/llm.py +++ b/openhands/llm/llm.py @@ -136,7 +136,7 @@ class LLM(RetryMixin, DebugMixin): if self.config.model.startswith('openhands/'): model_name = self.config.model.removeprefix('openhands/') self.config.model = f'litellm_proxy/{model_name}' - self.config.base_url = 'https://llm-proxy.app.all-hands.dev/' + self.config.base_url = _get_openhands_llm_base_url() logger.debug( f'Rewrote openhands/{model_name} to {self.config.model} with base URL {self.config.base_url}' ) @@ -851,3 +851,18 @@ class LLM(RetryMixin, DebugMixin): # let pydantic handle the serialization return [message.model_dump() for message in messages] + + +def _get_openhands_llm_base_url(): + # Get the API url if specified + lite_llm_api_url = os.getenv('LITE_LLM_API_URL') + if lite_llm_api_url: + return lite_llm_api_url + + # Fallback to using web_host. + web_host = os.getenv('WEB_HOST') + if web_host and ('.staging.' in web_host or web_host.startswith('staging')): + return 'https://llm-proxy.staging.all-hands.dev/' + + # Use the default + return 'https://llm-proxy.app.all-hands.dev/'