Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: planning agent auth error due to missing base_url (#13638)

Hiep Leed5ab11fccd7
diff --git a/openhands/app_server/app_conversation/live_status_app_conversation_service.py b/openhands/app_server/app_conversation/live_status_app_conversation_service.py
index b2dbda5882..f3010ad406 100644
--- a/openhands/app_server/app_conversation/live_status_app_conversation_service.py
+++ b/openhands/app_server/app_conversation/live_status_app_conversation_service.py
@@ -890,7 +890,9 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
"""
model = llm_model or user.llm_model
base_url = user.llm_base_url
- if model and model.startswith('openhands/'):
+ if model and (
+ model.startswith('openhands/') or model.startswith('litellm_proxy/')
+ ):
base_url = user.llm_base_url or self.openhands_provider_base_url
return LLM(
diff --git a/tests/unit/app_server/test_live_status_app_conversation_service.py b/tests/unit/app_server/test_live_status_app_conversation_service.py
index 23d90b136b..0a765b1dda 100644
--- a/tests/unit/app_server/test_live_status_app_conversation_service.py
+++ b/tests/unit/app_server/test_live_status_app_conversation_service.py
@@ -548,6 +548,40 @@ class TestLiveStatusAppConversationService:
# Assert
assert llm.base_url == 'https://llm-proxy.app.all-hands.dev/'
+ @pytest.mark.asyncio
+ async def test_configure_llm_and_mcp_litellm_proxy_model_uses_provider_default(
+ self,
+ ):
+ """litellm_proxy/* model (inherited by sub-conversations) falls back to provider base URL."""
+ # Arrange β€” simulates a sub-conversation inheriting the SDK-transformed model name
+ self.mock_user.llm_base_url = None
+ self.mock_user_context.get_mcp_api_key.return_value = None
+
+ # Act
+ llm, _ = await self.service._configure_llm_and_mcp(
+ self.mock_user, 'litellm_proxy/minimax-2.5', self.conversation_id
+ )
+
+ # Assert
+ assert llm.base_url == 'https://provider.example.com'
+
+ @pytest.mark.asyncio
+ async def test_configure_llm_and_mcp_litellm_proxy_model_prefers_user_base_url(
+ self,
+ ):
+ """litellm_proxy/* model uses user.llm_base_url when provided."""
+ # Arrange
+ self.mock_user.llm_base_url = 'https://user-llm.example.com'
+ self.mock_user_context.get_mcp_api_key.return_value = None
+
+ # Act
+ llm, _ = await self.service._configure_llm_and_mcp(
+ self.mock_user, 'litellm_proxy/minimax-2.5', self.conversation_id
+ )
+
+ # Assert
+ assert llm.base_url == 'https://user-llm.example.com'
+
@pytest.mark.asyncio
async def test_configure_llm_and_mcp_non_openhands_model_ignores_provider(self):
"""Non-openhands model ignores provider base URL and uses user base URL."""