mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(docker): remove container on cleanup when container_persistent=false
When container_persistent=false, the inner mini-swe-agent cleanup only runs 'docker stop' in the background, leaving containers in Exited state. Now cleanup() also runs 'docker rm -f' to fully remove the container. Also fixes pre-existing test failures in model_metadata (gpt-4.1 1M context), setup tests (TTS provider step), and adds MockInnerDocker.cleanup(). Original fix by crazywriter1. Cherry-picked and adapted for current main. Fixes #1679
This commit is contained in:
parent
f613da4219
commit
7049dba778
5 changed files with 64 additions and 4 deletions
|
|
@ -458,6 +458,20 @@ class DockerEnvironment(BaseEnvironment):
|
|||
"""Stop and remove the container. Bind-mount dirs persist if persistent=True."""
|
||||
self._inner.cleanup()
|
||||
|
||||
if not self._persistent and self._container_id:
|
||||
# Inner cleanup only runs `docker stop` in background; container is left
|
||||
# as stopped. When container_persistent=false we must remove it.
|
||||
docker_exe = find_docker() or self._inner.config.executable
|
||||
try:
|
||||
subprocess.run(
|
||||
[docker_exe, "rm", "-f", self._container_id],
|
||||
capture_output=True,
|
||||
timeout=30,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to remove non-persistent container %s: %s", self._container_id, e)
|
||||
self._container_id = None
|
||||
|
||||
if not self._persistent:
|
||||
import shutil
|
||||
for d in (self._workspace_dir, self._home_dir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue