Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent docker session #1998

Merged
merged 31 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
035229c
Persistent docker session
SmartManoj May 23, 2024
570141b
Merge branch 'main' into docker
SmartManoj May 23, 2024
700f76d
Removed outdated comment
SmartManoj May 23, 2024
6e5432c
made persist_session as default
SmartManoj May 23, 2024
eaffd72
disabled sandbox persistence in tests
SmartManoj May 24, 2024
24d7d0e
disabled sandbox persistence in tests
SmartManoj May 24, 2024
96e09a2
Merge branch 'main' into docker
SmartManoj May 24, 2024
25ce84c
Merge branch 'main' into docker
SmartManoj May 24, 2024
e7e8ed3
Merge branch 'main' into docker
neubig May 24, 2024
8256155
disabled removing persistant sandbox
SmartManoj May 24, 2024
9b9b070
Merge branch 'main' into docker
SmartManoj May 24, 2024
5f95303
Merge branch 'docker' of https://github.com/SmartManoj/Kevin into docker
SmartManoj May 24, 2024
38be74d
revert timeout change
SmartManoj May 24, 2024
0d2cb2d
Merge branch 'main' into docker
SmartManoj May 25, 2024
9a1d29b
load bashrc
SmartManoj May 25, 2024
c6b7f56
Merge branch 'main' into docker
SmartManoj May 25, 2024
4892a0a
Merge branch 'main' into docker
SmartManoj May 25, 2024
24b8105
fixed actions
SmartManoj May 25, 2024
39b09f5
fixed actions
SmartManoj May 25, 2024
516e629
Merge branch 'main' into docker
SmartManoj May 26, 2024
031f7e3
Merge branch 'main' into docker
SmartManoj May 27, 2024
a1eeb70
Merge branch 'main' into docker
SmartManoj May 27, 2024
b6a685e
Merge branch 'main' into docker
SmartManoj May 27, 2024
4da9605
reverted reset changes
SmartManoj May 27, 2024
ce293f6
Merge branch 'main' into docker
SmartManoj May 27, 2024
054d88d
removed default password
SmartManoj May 28, 2024
40073e0
Merge branch 'main' into docker
SmartManoj May 28, 2024
5ea6138
Update dummy-agent-test.yml
SmartManoj May 28, 2024
8511f42
Merge branch 'docker' of https://github.com/SmartManoj/Kevin into docker
SmartManoj May 28, 2024
cda7105
Update intro.mdx
SmartManoj May 28, 2024
9d5f411
Merge branch 'main' into docker
SmartManoj May 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Persistent docker session
  • Loading branch information
SmartManoj committed May 23, 2024
commit 035229ca19b8d6abbe201d6f70592748cc195a39
2 changes: 1 addition & 1 deletion agenthub/codeact_agent/codeact_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def step(self, state: State) -> Action:
{'role': 'system', 'content': self.system_message},
{
'role': 'user',
'content': f"Here is an example of how you can interact with the environment for task solving:\n{EXAMPLES}\n\nNOW, LET'S START!",
'content': f"Here is an example of how you can interact with the environment for task solving:\n{EXAMPLES}\n\nNOW, LET'S START!\n",
SmartManoj marked this conversation as resolved.
Show resolved Hide resolved
},
]

Expand Down
4 changes: 4 additions & 0 deletions opendevin/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ class AppConfig(metaclass=Singleton):
disable_color: bool = False
sandbox_user_id: int = os.getuid() if hasattr(os, 'getuid') else 1000
sandbox_timeout: int = 120
persist_session: bool = False
ssh_port: int | None = None
ssh_password: str | None = None
container_id: str | None = None
SmartManoj marked this conversation as resolved.
Show resolved Hide resolved
github_token: str | None = None
jwt_secret: str = uuid.uuid4().hex
debug: bool = False
Expand Down
1 change: 1 addition & 0 deletions opendevin/core/schema/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


class ConfigType(str, Enum):
# For frontend
LLM_CUSTOM_LLM_PROVIDER = 'LLM_CUSTOM_LLM_PROVIDER'
LLM_MAX_INPUT_TOKENS = 'LLM_MAX_INPUT_TOKENS'
LLM_MAX_OUTPUT_TOKENS = 'LLM_MAX_OUTPUT_TOKENS'
Expand Down
44 changes: 24 additions & 20 deletions opendevin/runtime/docker/ssh_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DockerSSHBox(Sandbox):
def __init__(
self,
container_image: str | None = None,
timeout: int = 120,
timeout: int = 180,
enyst marked this conversation as resolved.
Show resolved Hide resolved
sid: str | None = None,
):
logger.info(
Expand Down Expand Up @@ -232,28 +232,32 @@ def __init__(
if container_image is None
else container_image
)
self.container_name = self.container_name_prefix + self.instance_id
self.container_name = (
config.container_id or self.container_name_prefix + self.instance_id
)

# set up random user password
self._ssh_password = str(uuid.uuid4())
self._ssh_port = find_available_tcp_port()

self._ssh_password = config.ssh_password or str(uuid.uuid4())
self._ssh_port = config.ssh_port or find_available_tcp_port()
# always restart the container, cuz the initial be regarded as a new session
SmartManoj marked this conversation as resolved.
Show resolved Hide resolved
n_tries = 5
while n_tries > 0:
try:
self.restart_docker_container()
break
except Exception as e:
logger.exception(
'Failed to start Docker container, retrying...', exc_info=False
)
n_tries -= 1
if n_tries == 0:
raise e
time.sleep(5)
self.setup_user()

if not config.persist_session:
n_tries = 5
while n_tries > 0:
try:
self.restart_docker_container()
break
except Exception as e:
logger.exception(
'Failed to start Docker container, retrying...', exc_info=False
)
n_tries -= 1
if n_tries == 0:
raise e
time.sleep(5)
self.setup_user()
else:
self.container = self.docker_client.containers.get(self.container_name)
logger.info('Using existing Docker container')
try:
self.start_ssh_session()
except pxssh.ExceptionPxssh as e:
Expand Down
2 changes: 1 addition & 1 deletion opendevin/runtime/plugins/jupyter/execute_server
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class JupyterKernel:
)
self.heartbeat_callback.start()

async def execute(self, code, timeout=60):
async def execute(self, code, timeout=120):
if not self.ws:
await self._connect()

Expand Down