fix(automation): purge expired local-mode run workspaces - #277
Open
trungminhdo4-glitch wants to merge 4 commits into
Open
fix(automation): purge expired local-mode run workspaces#277trungminhdo4-glitch wants to merge 4 commits into
trungminhdo4-glitch wants to merge 4 commits into
Conversation
…ble retention period Add a periodic workspace purger for local mode that safely removes workspace directories for runs in terminal states (COMPLETED, FAILED, CANCELLED, SKIPPED) after a configurable retention period. - New openhands/automation/workspace_cleaner.py: purge_terminal_workspaces() queries terminal runs with completed_at < now - retention, deletes workspace dirs in bounded batches, logs bytes freed and errors. Never touches PENDING/RUNNING runs. Tolerates missing directories. - New config: AUTOMATION_WORKSPACE_RETENTION_SECONDS (default 7 days), AUTOMATION_PURGER_INTERVAL_SECONDS (default 1 hour), AUTOMATION_PURGER_BATCH_SIZE (default 50). - app.py: purger_loop background task (local mode only), initial startup purge, graceful shutdown. - tests/test_workspace_cleaner.py: 18 tests covering active-run protection, retention cutoff, batch size, missing dirs, all terminal states, empty DB, and workspace_base expansion. Fixes OpenHands#271
trungminhdo4-glitch
marked this pull request as ready for review
July 30, 2026 21:36
Author
|
HUMAN: (Owner-authorized; posted by my agent on my behalf.) I am supervising this contribution, and the final decisions remain mine. This PR is intentionally limited to terminal local-mode workspaces. I am treating active-run protection, bounded cleanup, path containment, and application-lifecycle ownership as the key review boundaries. The two lightweight PR checks pass; the four full fork workflows remain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Persistent local agent-server runs leave their workspaces under
${AUTOMATION_WORKSPACE_BASE}/automation-runs/<run_id>indefinitely.This eventually consumes significant local disk space.
Safety properties
Tests
A full Docker/PostgreSQL suite was not run locally.
GitHub Actions for this fork PR are awaiting maintainer approval.
Fixes #271
Disclosure: This contribution was prepared with AI assistance and independently
reviewed and tested locally before publication.