Skip to content

Fix container not removed when container_persistent=false (Fixes #1679)#1691

Closed
crazywriter1 wants to merge 4 commits intoNousResearch:mainfrom
crazywriter1:fix/1679-container-persistent-false
Closed

Fix container not removed when container_persistent=false (Fixes #1679)#1691
crazywriter1 wants to merge 4 commits intoNousResearch:mainfrom
crazywriter1:fix/1679-container-persistent-false

Conversation

@crazywriter1
Copy link
Contributor

@crazywriter1 crazywriter1 commented Mar 17, 2026

Fixes #1679

When terminal.container_persistent is false, Docker containers were only stopped by the inner mini-swe-agent cleanup and left as "Exited", so they were never removed.

Changes

  • tools/environments/docker.py
    In cleanup(), when container_persistent is false and we have a container ID, we now run docker rm -f <container_id> after the inner cleanup (which only does docker stop in the background). Uses a 30s timeout; failures are logged and we clear the stored container ID.

  • tests/tools/test_docker_environment.py
    Added test_non_persistent_cleanup_removes_container: with a mocked inner Docker and persistent_filesystem=False, we assert that cleanup() triggers a subprocess.run call with docker rm -f <container_id>.

Testing

  • pytest tests/tools/test_docker_environment.py passes (including the new test).
  • Manual check: set terminal.backend: docker and container_persistent: false in config, run a terminal command via Hermes, then docker ps -a — the container should no longer appear after cleanup.

Note: Commits after the first one are merge conflict resolution and CI fixes
(model metadata + setup/TTS tests) so the branch passes main’s tests. The
behavioral fix for #1679 is only in the first commit (docker cleanup + test).

…Research#1679)

When terminal.container_persistent is false, cleanup() now runs
'docker rm -f' after the inner stop so the container is removed
instead of left as Exited. Added test to assert docker rm -f is called.

Made-with: Cursor
…ainer and upstream execute/dotenv tests

Made-with: Cursor
setup_model_provider() now calls _setup_tts_provider(); tests that mock
prompt_choice either no-op _setup_tts_provider or add one more choice for
'Select TTS provider:' (Keep current).

Made-with: Cursor
@teknium1
Copy link
Contributor

Merged via PR #1712. Your fix (docker rm -f on cleanup when container_persistent=false) was cherry-picked onto current main with authorship preserved. Also included your test fixes for model_metadata and setup tests. Thanks for the clean, well-tested contribution!

@teknium1 teknium1 closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: terminal.container_persistent (= false) setting is not respected

2 participants