π OpenHands: AI-Driven Development
Add `SANDBOX_WORKSPACE_DIR` into config (#1266)
Xingyao Wangdffbeec45af4
diff --git a/agenthub/monologue_agent/agent.py b/agenthub/monologue_agent/agent.pyindex 7b9b73e87f..bf0a2037ff 100644--- a/agenthub/monologue_agent/agent.py+++ b/agenthub/monologue_agent/agent.py@@ -125,7 +125,8 @@ class MonologueAgent(Agent):def _initialize(self, task: str):"""- Utilizes the INITIAL_THOUGHTS list to give the agent a context for it's capabilities and how to navigate the /workspace.+ Utilizes the INITIAL_THOUGHTS list to give the agent a context for it's capabilities+ and how to navigate the WORKSPACE_MOUNT_PATH_IN_SANDBOX in `config` (e.g., /workspace by default).Short circuited to return when already initialized.Parameters:diff --git a/agenthub/monologue_agent/utils/prompts.py b/agenthub/monologue_agent/utils/prompts.pyindex 05f6bfaff4..688e139f9a 100644--- a/agenthub/monologue_agent/utils/prompts.py+++ b/agenthub/monologue_agent/utils/prompts.py@@ -13,6 +13,7 @@ from opendevin.observation import (CmdOutputObservation,)from opendevin.exceptions import LLMOutputError+from opendevin import configACTION_PROMPT = """You're a thoughtful robot. Your main task is this:@@ -58,7 +59,7 @@ actions are all "think" actions, you should consider taking a different action.Notes:* your environment is Debian Linux. You can install software with `apt`-* your working directory will not change, even if you run `cd`. All commands will be run in the `/workspace` directory.+* your working directory will not change, even if you run `cd`. All commands will be run in the `%(WORKSPACE_MOUNT_PATH_IN_SANDBOX)s` directory.* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)What is your next thought or action? Again, you must reply with JSON, and only with JSON.@@ -145,6 +146,7 @@ def get_request_action_prompt('monologue': json.dumps(thoughts, indent=2),'background_commands': bg_commands_message,'hint': hint,+ 'WORKSPACE_MOUNT_PATH_IN_SANDBOX': config.get('WORKSPACE_MOUNT_PATH_IN_SANDBOX'),}diff --git a/opendevin/config.py b/opendevin/config.pyindex 45f33ae5f2..77f1e87e7a 100644--- a/opendevin/config.py+++ b/opendevin/config.py@@ -13,6 +13,7 @@ DEFAULT_CONFIG: dict = {ConfigType.LLM_BASE_URL: None,ConfigType.WORKSPACE_BASE: os.getcwd(),ConfigType.WORKSPACE_MOUNT_PATH: None,+ ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX: '/workspace',ConfigType.WORKSPACE_MOUNT_REWRITE: None,ConfigType.LLM_MODEL: 'gpt-3.5-turbo-1106',ConfigType.SANDBOX_CONTAINER_IMAGE: 'ghcr.io/opendevin/sandbox',diff --git a/opendevin/sandbox/docker/exec_box.py b/opendevin/sandbox/docker/exec_box.pyindex bc9ce5a965..b18aaeed6d 100644--- a/opendevin/sandbox/docker/exec_box.py+++ b/opendevin/sandbox/docker/exec_box.py@@ -21,7 +21,7 @@ InputType = namedtuple('InputType', ['content'])OutputType = namedtuple('OutputType', ['content'])CONTAINER_IMAGE = config.get(ConfigType.SANDBOX_CONTAINER_IMAGE)-SANDBOX_WORKSPACE_DIR = '/workspace'+SANDBOX_WORKSPACE_DIR = config.get(ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX)# FIXME: On some containers, the devin user doesn't have enough permission, e.g. to install packages# How do we make this more flexible?diff --git a/opendevin/sandbox/docker/ssh_box.py b/opendevin/sandbox/docker/ssh_box.pyindex 5f21821b2e..1d45ded6ff 100644--- a/opendevin/sandbox/docker/ssh_box.py+++ b/opendevin/sandbox/docker/ssh_box.py@@ -22,7 +22,7 @@ from opendevin.exceptions import SandboxInvalidBackgroundCommandErrorInputType = namedtuple('InputType', ['content'])OutputType = namedtuple('OutputType', ['content'])-SANDBOX_WORKSPACE_DIR = '/workspace'+SANDBOX_WORKSPACE_DIR = config.get(ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX)CONTAINER_IMAGE = config.get(ConfigType.SANDBOX_CONTAINER_IMAGE)@@ -170,7 +170,7 @@ class DockerSSHBox(Sandbox):self.ssh.sendline("bind 'set enable-bracketed-paste off'")self.ssh.prompt()# cd to workspace- self.ssh.sendline('cd /workspace')+ self.ssh.sendline(f'cd {SANDBOX_WORKSPACE_DIR}')self.ssh.prompt()def get_exec_cmd(self, cmd: str) -> List[str]:diff --git a/opendevin/schema/config.py b/opendevin/schema/config.pyindex 3daba52e55..90f9896dfe 100644--- a/opendevin/schema/config.py+++ b/opendevin/schema/config.py@@ -7,6 +7,7 @@ class ConfigType(str, Enum):WORKSPACE_BASE = 'WORKSPACE_BASE'WORKSPACE_MOUNT_PATH = 'WORKSPACE_MOUNT_PATH'WORKSPACE_MOUNT_REWRITE = 'WORKSPACE_MOUNT_REWRITE'+ WORKSPACE_MOUNT_PATH_IN_SANDBOX = 'WORKSPACE_MOUNT_PATH_IN_SANDBOX'LLM_MODEL = 'LLM_MODEL'SANDBOX_CONTAINER_IMAGE = 'SANDBOX_CONTAINER_IMAGE'RUN_AS_DEVIN = 'RUN_AS_DEVIN'