Self-hosted runner can now delete a session's leftover files when the session ends
The claude self-hosted-runner command line tool gets a new --remove-session-state flag (also settable via the SELF_HOSTED_RUNNER_REMOVE_SESSION_STATE environment variable). When enabled, ending a session now removes that session's stored state under its _sessions/ folder, including its Claude config directory (transcript copy, shell snapshots, session environment, file history, debug log), staged uploads, per-session git configuration, and the session's working directory.
- Accepts
true/false/1/0, and defaults totrueif you pass the flag with no value. - Off by default, so existing behavior is unchanged unless you turn it on.
- Cleanup is best-effort: files are safely renamed then deleted, and at startup the runner logs whether these per-session files will be removed or kept.
- The runner logs how many of the targeted paths were actually removed versus already absent, and this also affects whether the debug log tail is sent to server-side session diagnostics or kept on disk.
This lets self-hosted runner operators avoid accumulating leftover session files (transcripts, uploads, git config, working directories) on disk after each session, which matters for storage management and for not retaining session data longer than needed.
The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.
| `--remove-session-state [bool]` | `SELF_HOSTED_RUNNER_REMOVE_SESSION_STATE` | off | Remove a session's per-session directories under `<base-dir>/_sessions/` when the session ends on this runner, whatever the outcome. [Reuse a pre-warmed …self-hosted-environments-reference see the edit
A small documentation edit on Self-hosted environments reference touched a line naming SELF_HOSTED_RUNNER_REMOVE_SESSION_STATE after this…
Added claude self-hosted-runner --remove-session-state (default off): delete each session's per-session directories under…
New in this build: SELF_HOSTED_RUNNER_REMOVE_SESSION_STATE