Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Revert "fix(acp): route pending message delivery through correct agent-server prefix" (#14318)

simonrosenbergc228f803bd45
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 9c75a38470..0fd378bf15 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
@@ -433,7 +433,6 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
conversation_id=info.id,
agent_server_url=agent_server_url,
session_api_key=sandbox.session_api_key,
- agent_kind=agent_kind,
)
except Exception as exc:
@@ -1620,7 +1619,6 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
conversation_id: UUID,
agent_server_url: str,
session_api_key: str,
- agent_kind: str = 'openhands',
) -> None:
"""Process pending messages queued before conversation was ready.
@@ -1632,7 +1630,6 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
conversation_id: The real conversation ID
agent_server_url: URL of the agent server
session_api_key: API key for authenticating with agent server
- agent_kind: Discriminator for agent-server route prefix ('acp' or 'openhands')
"""
# Convert UUIDs to strings for the pending message service
# The frontend uses task-{uuid.hex} format (no hyphens), matching OpenHandsUUID serialization
@@ -1672,9 +1669,9 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
try:
# Serialize content objects to JSON-compatible dicts
content_json = [item.model_dump() for item in msg.content]
- router_path = _agent_kind_to_router_path(agent_kind)
+ # Use the events endpoint which handles message sending
response = await self.httpx_client.post(
- f'{agent_server_url}/api/{router_path}/{conversation_id_str}/events',
+ f'{agent_server_url}/api/conversations/{conversation_id_str}/events',
json={
'role': msg.role,
'content': content_json,
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 a75eefa6e6..13800bc528 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
@@ -3388,122 +3388,3 @@ class TestBuildAcpStartConversationRequestSecrets:
# acp_env must win; the UI-saved key must NOT overwrite it
assert request.agent.acp_env.get('ANTHROPIC_API_KEY') == 'sk-explicit-override'
-
-
-class TestProcessPendingMessages:
- """Unit tests for _process_pending_messages URL routing.
-
- Verifies that pending messages are delivered to the correct agent-server
- endpoint depending on agent_kind: /api/conversations/ for 'openhands' and
- /api/acp/conversations/ for 'acp'.
- """
-
- def _make_service(self, mock_httpx_client, mock_pending_service):
- service = LiveStatusAppConversationService.__new__(
- LiveStatusAppConversationService
- )
- service.httpx_client = mock_httpx_client
- service.pending_message_service = mock_pending_service
- return service
-
- @pytest.mark.asyncio
- async def test_openhands_agent_uses_standard_events_url(self):
- from openhands.agent_server.models import TextContent
-
- task_id = uuid4()
- conversation_id = uuid4()
- agent_server_url = 'http://agent-server:8000'
- session_api_key = 'sk-test'
-
- mock_response = Mock()
- mock_response.raise_for_status = Mock()
-
- mock_httpx = Mock()
- mock_httpx.post = AsyncMock(return_value=mock_response)
-
- mock_pending = Mock()
- mock_pending.update_conversation_id = AsyncMock(return_value=0)
- mock_pending.get_pending_messages = AsyncMock(
- return_value=[
- Mock(
- id='msg-1',
- role='user',
- content=[TextContent(type='text', text='hello')],
- )
- ]
- )
- mock_pending.delete_messages_for_conversation = AsyncMock(return_value=1)
-
- service = self._make_service(mock_httpx, mock_pending)
- await service._process_pending_messages(
- task_id=task_id,
- conversation_id=conversation_id,
- agent_server_url=agent_server_url,
- session_api_key=session_api_key,
- agent_kind='openhands',
- )
-
- posted_url = mock_httpx.post.call_args[0][0]
- assert '/api/conversations/' in posted_url
- assert '/api/acp/' not in posted_url
- assert str(conversation_id) in posted_url
-
- @pytest.mark.asyncio
- async def test_acp_agent_uses_acp_events_url(self):
- from openhands.agent_server.models import TextContent
-
- task_id = uuid4()
- conversation_id = uuid4()
- agent_server_url = 'http://agent-server:8000'
- session_api_key = 'sk-test'
-
- mock_response = Mock()
- mock_response.raise_for_status = Mock()
-
- mock_httpx = Mock()
- mock_httpx.post = AsyncMock(return_value=mock_response)
-
- mock_pending = Mock()
- mock_pending.update_conversation_id = AsyncMock(return_value=0)
- mock_pending.get_pending_messages = AsyncMock(
- return_value=[
- Mock(
- id='msg-1',
- role='user',
- content=[TextContent(type='text', text='hello')],
- )
- ]
- )
- mock_pending.delete_messages_for_conversation = AsyncMock(return_value=1)
-
- service = self._make_service(mock_httpx, mock_pending)
- await service._process_pending_messages(
- task_id=task_id,
- conversation_id=conversation_id,
- agent_server_url=agent_server_url,
- session_api_key=session_api_key,
- agent_kind='acp',
- )
-
- posted_url = mock_httpx.post.call_args[0][0]
- assert '/api/acp/conversations/' in posted_url
- assert str(conversation_id) in posted_url
-
- @pytest.mark.asyncio
- async def test_no_pending_messages_skips_post(self):
- mock_httpx = Mock()
- mock_httpx.post = AsyncMock()
-
- mock_pending = Mock()
- mock_pending.update_conversation_id = AsyncMock(return_value=0)
- mock_pending.get_pending_messages = AsyncMock(return_value=[])
-
- service = self._make_service(mock_httpx, mock_pending)
- await service._process_pending_messages(
- task_id=uuid4(),
- conversation_id=uuid4(),
- agent_server_url='http://agent-server:8000',
- session_api_key='sk-test',
- )
-
- mock_httpx.post.assert_not_called()