From f4e621f7d834fe8dc879dd4f4fbf3e14d3d986cf Mon Sep 17 00:00:00 2001 From: hekaru-agent Date: Fri, 8 May 2026 06:20:35 -0700 Subject: [PATCH] fix(cron): clean up job output dir in remove_job remove_job() deletes the job from cron/jobs.json but leaves the per-job output directory at ~/.hermes/cron/output/{job_id}/ behind. Over time this accumulates orphaned dirs that never get reclaimed. Adopted from #13510 by @hekaru-agent; the honcho RLock half of that PR was already salvaged in commit dad021745 so this lands the remaining cron cleanup hunk on its own. --- cron/jobs.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cron/jobs.py b/cron/jobs.py index 93ad4c17fb..566db1e6db 100644 --- a/cron/jobs.py +++ b/cron/jobs.py @@ -8,6 +8,7 @@ Output is saved to ~/.hermes/cron/output/{job_id}/{timestamp}.md import copy import json import logging +import shutil import tempfile import threading import os @@ -696,6 +697,10 @@ def remove_job(job_id: str) -> bool: jobs = [j for j in jobs if j["id"] != job_id] if len(jobs) < original_len: save_jobs(jobs) + # Clean up output directory to prevent orphaned dirs accumulating + job_output_dir = OUTPUT_DIR / job_id + if job_output_dir.exists(): + shutil.rmtree(job_output_dir) return True return False