Fix Windows prompt refinement: ensure 'bash' is replaced with 'powershell' in all prompts (#10179)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Boxuan Li
2025-08-08 20:28:36 -07:00
committed by GitHub
parent 3eecac2003
commit 803bdced9c
4 changed files with 194 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import re
import sys
from litellm import ChatCompletionToolParam, ChatCompletionToolParamFunctionChunk
@@ -37,7 +38,16 @@ _SHORT_BASH_DESCRIPTION = """Execute a bash command in the terminal.
def refine_prompt(prompt: str):
if sys.platform == 'win32':
return prompt.replace('bash', 'powershell')
# Replace 'bash' with 'powershell' including tool names like 'execute_bash'
# First replace 'execute_bash' with 'execute_powershell' to handle tool names
result = re.sub(
r'\bexecute_bash\b', 'execute_powershell', prompt, flags=re.IGNORECASE
)
# Then replace standalone 'bash' with 'powershell'
result = re.sub(
r'(?<!execute_)(?<!_)\bbash\b', 'powershell', result, flags=re.IGNORECASE
)
return result
return prompt