[BUG] Startup cleanup deletes live sibling sessions' Bash task output under the shared project temp root
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
In multi-session use on one machine (several interactive Claude Code sessions plus background subagents sharing one project temp root under %LOCALAPPDATA%\Temp\claude\<project-slug>\<session-id>\), a new session's startup cleanup deletes the Bash background-task output captures (tasks/<task-id>.output) of sibling sessions that are still running. Liveness appears to be judged by the output file's modification time rather than the session's process or lock. Result: monitors, background dispatches and parent sessions lose their task output mid-execution, silently. First seen 1 Sep 2026, recurring since.
What Should Happen?
Cleanup must not touch directories or files of other sessions that are alive. Liveness should be judged by the session process or lock state, not by inactivity of a captured output file; a genuinely dead session should need evidence (process gone, lock stale beyond a fixed threshold) before deletion.
Error Messages/Logs
None. The deletion is silent; the parent session reads an empty or truncated <task-id>.output file.
Steps to Reproduce
In project P, start Claude Code session A and run a Bash command with run_in_background that lasts more than a few minutes (a polling loop is enough).
Before it finishes, start a second Claude Code session B in the same project P.
Session B's startup cleanup runs.
Check session A's tasks/<task-id>.output: it has been deleted or truncated while the command is still running.
Observed pattern, timing-dependent; repeatable under heavy multi-session use.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
unknown
Claude Code Version
2.1.211 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
Workarounds adopted: judge long-running dispatch outcomes from a durable project log rather than the harness capture; write background outputs to durable project paths; avoid starting new sessions mid-dispatch. Root cause is harness-side; no local hooks or settings trigger or control this. Session and task ids with timestamps available on request.