Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat: pass WEB_HOST to agent context in V1 conversations (#14050)

Rohit Malhotra237e9f530e08
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 bce1a0eab6..f8bd2207bf 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
@@ -1248,6 +1248,15 @@ class LiveStatusAppConversationService(AppConversationServiceBase):
else:
effective_suffix = PLANNING_AGENT_INSTRUCTION
+ # --- web host context -----------------------------------------------
+ # Add WEB_HOST to agent context if available
+ if self.web_url:
+ web_host_context = f'<HOST>\n{self.web_url}\n</HOST>'
+ if effective_suffix:
+ effective_suffix = f'{effective_suffix}\n\n{web_host_context}'
+ else:
+ effective_suffix = web_host_context
+
# --- tools ----------------------------------------------------------
if agent_type == AgentType.PLAN:
plan_path = None
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 d6eb2b56ea..698c50913d 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
@@ -1093,8 +1093,13 @@ class TestLiveStatusAppConversationService:
assert result.agent.llm.model == 'gpt-4'
# Secrets are injected via agent_context
assert result.agent.agent_context.secrets == mock_secrets
- # System message suffix is passed through
- assert result.agent.agent_context.system_message_suffix == 'Test suffix'
+ # System message suffix includes the original suffix and web host context
+ assert 'Test suffix' in result.agent.agent_context.system_message_suffix
+ assert '<HOST>' in result.agent.agent_context.system_message_suffix
+ assert (
+ 'https://test.example.com'
+ in result.agent.agent_context.system_message_suffix
+ )
# Workspace points to the repo subdirectory
assert result.workspace.working_dir == '/test/dir/repo'