[#957] Lifecycle-aware cleanup of agent backend temp dirs#960
Open
realproject7 wants to merge 1 commit into
Open
[#957] Lifecycle-aware cleanup of agent backend temp dirs#960realproject7 wants to merge 1 commit into
realproject7 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #957
What
Adds
server/temp-cleanup.js— a stale-only sweep of agent backend temp — wired into two lifecycle points inserver/index.js:stopAgentSession): deferred fire-and-forget sweep after every stop/reset/restart.Targets (confirmed on the VPS that hit #957):
/tmp/claude-{uid}— Claude Code's unbounded TMPDIR override (the 909 MB / 63k-inode quota killer)./tmp/gemini-client-error-*.json— stray Gemini crash dumps (observed on the VPS)./tmpusage (state lives in~/.codex) → nothing to sweep.Safety design
/tmp/claude-{uid}is shared by every claude agent of the user, so teardown of one agent must never delete another live agent's files. Deletion requires age >max_age_hours(default 72h) onmax(mtime, atime, ctime)— systemd-tmpfiles semantics, so anything a live session touches stays fresh.backendTempSweepTickalso has its own try/catch + re-entrancy guard).process.getuid(Windows) → claude sweep skipped; gemini glob matches nothing where absent. Non-matching files at the temp root are never touched.temp_cleanup: { enabled, max_age_hours }inconfig.json(default on / 72h;enabled:falseopts out).server/(shipped dir) per the Settings: changing an agent's Command doesn't update mcp_inject — converting to gemini leaves stale 'flag' and crashes the CLI #937/2.3.4 crash-loops on fresh install: server requires src/lib/injectMode.js, not in npm files whitelist (#937 regression) + add pack-smoke guard #939 rule; pack-smoke covers it.Docs
docs/troubleshooting.md: new section for the silent-exit-1 symptom (it masquerades as a sandbox failure) with diagnosis + manual recovery.docs/install-vps.md: note aboutusrquotaVPS images.Verification
server/temp-cleanup.test.js: stale file/dir removed (recursively), fresh spared, claude dir itself kept, gemini dumps matched, unrelated old files never touched, missing dir / Windows-no-uid / bogus root → clean no-op, settings defaults + opt-out. All fixture-based with injected uid/now/tmpRoot — never touches the real /tmp.node --checkboth files · boot smoke (QUADWORK_SKIP_LISTEN=1 require) OK ·npm run buildOK.🤖 Generated with Claude Code