mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-05 16:33:08 +00:00
fix: add automatic temp folder cleanup at Maestro startup
Problem: When AutoForge runs agents that use Playwright for browser testing or mongodb-memory-server for database tests, temporary files accumulate in the system temp folder (%TEMP% on Windows, /tmp on Linux/macOS). These files are never cleaned up automatically and can consume hundreds of GB over time. Affected temp items: - playwright_firefoxdev_profile-* (browser profiles) - playwright-artifacts-* (test artifacts) - playwright-transform-cache - mongodb-memory-server* (MongoDB binaries) - ng-* (Angular CLI temp) - scoped_dir* (Chrome/Chromium temp) - .78912*.node (Node.js native module cache, ~7MB each) - claude-*-cwd (Claude CLI working directory files) - mat-debug-*.log (Material/Angular debug logs) Solution: - New temp_cleanup.py module with cleanup_stale_temp() function - Called at Maestro (orchestrator) startup in autonomous_agent_demo.py - Only deletes files/folders older than 1 hour (safe for running processes) - Runs every time the Play button is clicked or agent auto-restarts - Reports cleanup stats: dirs deleted, files deleted, MB freed Why cleanup at Maestro startup: - Reliable hook point (runs on every agent start, including auto-restart after rate limits which happens every ~5 hours) - No need for background timers or scheduled tasks - Cleanup happens before new temp files are created Testing: - Tested on Windows with 958 items in temp folder - Successfully cleaned 45 dirs, 758 files, freed 415 MB - Files younger than 1 hour correctly preserved Closes #155 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -263,6 +263,17 @@ def main() -> None:
|
||||
)
|
||||
else:
|
||||
# Entry point mode - always use unified orchestrator
|
||||
# Clean up stale temp files before starting (prevents temp folder bloat)
|
||||
from temp_cleanup import cleanup_stale_temp
|
||||
cleanup_stats = cleanup_stale_temp()
|
||||
if cleanup_stats["dirs_deleted"] > 0 or cleanup_stats["files_deleted"] > 0:
|
||||
mb_freed = cleanup_stats["bytes_freed"] / (1024 * 1024)
|
||||
print(
|
||||
f"[CLEANUP] Removed {cleanup_stats['dirs_deleted']} dirs, "
|
||||
f"{cleanup_stats['files_deleted']} files ({mb_freed:.1f} MB freed)",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
from parallel_orchestrator import run_parallel_orchestrator
|
||||
|
||||
# Clamp concurrency to valid range (1-5)
|
||||
|
||||
Reference in New Issue
Block a user