From 812fe98a8c3dedaa665f926c2ab05972b34f8f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Thu, 6 Mar 2025 19:05:08 +0530 Subject: [PATCH] restrict runtime info --- .../codeact_agent/prompts/default/additional_info.j2 | 1 + openhands/utils/prompt.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openhands/agenthub/codeact_agent/prompts/default/additional_info.j2 b/openhands/agenthub/codeact_agent/prompts/default/additional_info.j2 index 0289ded25ea0..1ad2c78b67ba 100644 --- a/openhands/agenthub/codeact_agent/prompts/default/additional_info.j2 +++ b/openhands/agenthub/codeact_agent/prompts/default/additional_info.j2 @@ -18,5 +18,6 @@ each of which has a corresponding port: When starting a web server, use the corresponding ports. You should also set any options to allow iframes and CORS requests, and allow the server to be accessed from any host (e.g. 0.0.0.0). +Only create the server if the user has requested it. {% endif %} diff --git a/openhands/utils/prompt.py b/openhands/utils/prompt.py index 4985f227897c..c7209016fc46 100644 --- a/openhands/utils/prompt.py +++ b/openhands/utils/prompt.py @@ -225,10 +225,14 @@ def add_info_to_initial_message( repo_instructions += '\n\n' repo_instructions += microagent.content + server_keywords = ['fastapi', 'flask', 'django'] + is_runtime_info_needed = any(keyword in repo_instructions for keyword in server_keywords) + + additional_info = self.additional_info_template.render( repository_instructions=repo_instructions, repository_info=self.repository_info, - runtime_info=self.runtime_info, + runtime_info=self.runtime_info if is_runtime_info_needed else None, ).strip() # Insert the new content at the start of the TextContent list