Skill /tmp scratch files leak when a run ends before its final cleanup step
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 197
- Forks
- 51
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 94
Description
What's happening
The docs-only skills the wizard runs (e.g. remediate-3000, cross-sell-3000 in context-mill) write JSON scratch files to /tmp/ across their steps, and delete them only in their final step.
If a run ends before reaching that final step, an [ABORT], an error, a rate-limit, or a kill, those files are left behind. The wizard never sweeps them.
Example leftovers:
- /tmp/posthog-remediation-plan.json, /tmp/posthog-remediation-env.json
- /tmp/posthog-cross-sell-opportunities.json, /tmp/posthog-cross-sell-plan.json, /tmp/posthog-cross-sell-env.json
Why the wizard can't catch it today
The wizard only understands two things a skill emits: [STATUS] and [ABORT]. On [ABORT] it kills the run and calls wizardAbort(), which runs only the functions registered in cleanupFns. None of those touch the skill's /tmp/ files. The wizard uses fixed /tmp/ paths (src/utils/paths.ts) and has no knowledge of the skill's scratch filenames, so it can't sweep them as-is.
Relevant code:
- src/lib/agent/agent-interface.ts (~1097-1118): [ABORT] detection, kills the run
- src/lib/agent/wizard-abort.ts: the cleanupFns list that runs on abort/exit
- src/utils/paths.ts: fixed /tmp/ paths, no managed temp dir
Impact
Low-harm: filenames are fixed so the next full run overwrites them, and /tmp/ clears on reboot. But interrupted runs leave orphaned files, which is confusing for anyone inspecting /tmp/ and slightly untidy.
Options
-
Wizard-level sweep (this repo): register a cleanup in the wizardAbort / cleanupFns path that removes known skill temp paths on any exit, including abort and error. Needs a convention for which paths to sweep (e.g. a glob like /tmp/posthog-*-plan.json, *-env.json, *-opportunities.json), which couples the wizard to skill filenames.
-
Skill-level self-heal (context-mill): have each skill rm -f its own temp files at the START of step 1, before writing anything, so an interrupted prior run gets cleaned on the next run. No wizard changes, and the skill already knows its own filenames. This is the lower-coupling fix.
Leaning toward option 2 for new skills, but filing here so the wizard team can decide whether a generic exit-time sweep is worth owning for all skills.
Repro
Run a skill that writes /tmp/ scratch files, interrupt it before the final step (e.g. trigger an [ABORT] or Ctrl-C), then check /tmp/ for leftover posthog-*.json files.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/lib/agent/agent-interface.ts around the [ABORT] handling, src/lib/agent/wizard-abort.ts cleanupFns, and src/utils/paths.ts. Reproduce an interrupted skill run and inspect /tmp; first decide whether wizard-level cleanup or skill-level self-healing is in scope, then verify the chosen approach removes the relevant scratch files after abort and error paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100