disk-cleanup
$FLOWLY_HOME and /tmp/flowly-*. Zero agent involvement.What it does
The agent regularly creates throwaway files: test_*.py while debugging, tmp_* for staging output, cron job logs that pile up over weeks. Without disk-cleanup, these accumulate forever — your ~/.flowly/ grows by megabytes per session.
disk-cleanup hooks into the agent runtime, watches every file the agent creates, and silently cleans them up at the end of each turn (for test files) or after configured retention windows (for temp / cron output). The agent never knows about it.
cleanup_disk tool the agent calls when it remembers to. But the agent forgets, gets distracted, or runs into context limits — temp files would still accumulate. A hook is invisible: it runs whether or not the agent cooperates.How it works
Two hooks wired in at register(ctx):
def register(ctx):
ctx.register_hook("post_tool_call", on_post_tool_call)
ctx.register_hook("on_session_end", on_session_end)
ctx.register_command("disk-cleanup", handler=slash_handler, ...)post_tool_callfires after every successfulwrite_file,edit_file, orexectool call. The hook scans the params/output for paths inside$FLOWLY_HOMEmatching one of the tracked patterns and adds them totracked.json.on_session_endfires at the end of each turn (every user message + agent reply pair). Tracked files past their retention window are deleted. Failures are logged, never raised.
The slash command /disk-cleanup lets the user run cleanup manually, view status, or untrack files. It never modifies the tracking store except via explicit subcommands.
Cleanup rules
Files are categorized at track time and cleaned according to category-specific retention. Anything outside these categories is ignored.
| Pattern | Category | Retention |
|---|---|---|
test_*, tmp_*, *.test.py | test | end of every turn |
$FLOWLY_HOME/cron/* | cron-output | 14 days |
$FLOWLY_HOME/cache/* | temp | 7 days |
| research files | research | 30 days, prompts before delete |
| chrome user-data dirs | chrome-profile | 14 days, prompts |
Safety guarantees
Plugin-level safety is enforced before anything is added to the tracking store, not just at delete time:
- Path scope — only files inside
$FLOWLY_HOMEor/tmp/flowly-*are eligible. Windows mounts (/mnt/c), system paths, anything under~/Documents— all rejected at track time. - Protected top-level dirs — even inside
$FLOWLY_HOME, these are never tracked:sessions, skills, plugins, credentials, audit, workspace, profiles, logs, memories, trajectories, subagents, screenshots, media. - State directory — the plugin's own state at
$FLOWLY_HOME/disk-cleanup/is excluded self-referentially. - Error containment — any failure during tracking or deletion is logged to
$FLOWLY_HOME/disk-cleanup/cleanup.logand swallowed. The agent loop is never affected.
$FLOWLY_HOME/ root (e.g. ~/.flowly/test_my_data.py), it will be deleted at session end. Don't use ~/.flowly/ as a working directory — keep your own files in ~/.flowly/workspace/ (which is protected) or outside Flowly entirely.Slash commands
/disk-cleanup status Per-category breakdown + 10 largest tracked files
/disk-cleanup dry-run Preview what /quick would delete
/disk-cleanup quick Run safe cleanup now (no prompts)
/disk-cleanup track <path> <category> Manually add a path
/disk-cleanup forget <path> Remove from tracking (does not delete)
/disk-cleanup help Usage helpCategories accepted by track: temp, test, research, download, chrome-profile, cron-output, other.
State files
$FLOWLY_HOME/disk-cleanup/
├── tracked.json Currently tracked paths with timestamps + category
├── tracked.json.bak Backup written before each save
└── cleanup.log Append-only audit log (TRACKED, DELETED, ERROR events)To inspect what's been deleted recently:
tail -50 ~/.flowly/disk-cleanup/cleanup.logOpting out
flowly plugins disable disk-cleanup
flowly service restartState files at $FLOWLY_HOME/disk-cleanup/ are preserved across disable / re-enable, so re-enabling later resumes tracking from the previous state.
flowly/plugins_bundled/disk-cleanup/. Originally contributed to Hermes Agent by @LVT382009 (PR #12212). Ported to Flowly with adaptations for the local plugin API.