[BUG] Sonnet 5.5 subagents issue a throwaway Write ("x" / "placeholder") to a mangled scratchpad path, leaving junk files under the temp root
What happens
Subagents running on claude-sonnet-5-5 occasionally emit a Write tool call that nothing asked for: the content is a single token (x, x\n, or placeholder\n) and the path is the session scratchpad path with the project slug broken by a slash. The very next call is the intended Write to the correct scratchpad path. Because Write creates missing parent directories, the stray call succeeds and leaves a file and a directory tree behind under the Claude temp root.
Shape of the two consecutive calls (paths generalized):
Write /private/tmp/claude-<uid>/-Users-<user>/<dir>-<project>/x content: "x"
Write /private/tmp/claude-<uid>/-Users-<user>-<dir>-<project>/<session-uuid>/scratchpad/body.md content: <the real file>
Observed variants of the stray path: -Users-<user>/<dir>-<project>/x, -Users-<user>/<dir>/x, -Users-<user>/<dir>/placeholder, -Users-<user>/<dir>/body.md, -Users-<user>/<dir>-<project>/placeholder-unused. In every case the slug -Users-<user>-<dir>-<project> is split at the first dash after the user name, and the session uuid and scratchpad/ segments are missing.
Why this looks like a model-side issue
- The file is created by a
tool_usethe model emitted, not by Claude Code itself. Each transcript shows theWritecall and theFile created successfullyresult. - The sandbox is not enabled in these profiles, and the sandbox governs Bash rather than
Write, so this is unrelated to the sandbox placeholder reports (#81602, #83497). - It is not a writability probe: in one transcript the agent had already written three files to the correct scratchpad (
b1.md,b2.md,b3.md) before the strayWriteofx, and then wroteb4.mdnormally. - No text or reasoning precedes the stray call. The thinking blocks around it are empty, and nothing in the agent's instructions asks for a test or placeholder file.
Frequency and versions
- 19 occurrences across subagent transcripts between 2026-09-29 and 2026-10-08, in two separate config directories.
- Every occurrence is on
claude-sonnet-5-5. - Claude Code 2.1.284, 2.1.285, 2.1.286, 2.1.288, 2.1.289, 2.1.291, 2.1.292 and 2.1.293, so it does not track a single CLI release.
- macOS 15 (Darwin 24.6).
- Most occurrences come from custom subagents whose job ends in writing one or more Markdown bodies into the scratchpad and passing them to a CLI with
--body-file; the step right before the stray call is usually amkdir -pof a scratchpad subdirectory or a previous scratchpadWrite.
Expected
The model writes only the files its task needs, at the scratchpad path it was given, with no throwaway file before it.
Workaround
A PreToolUse hook on Write|Edit|NotebookEdit that denies any path inside /private/tmp/claude-<uid>/ (or /tmp/claude-<uid>/) not of the form <root>/<existing project slug>/<session uuid>/.... The denial reason tells the model the path is mistyped and that no placeholder is needed; the agent then continues with the correct path.
Reproduction notes
The behavior is intermittent. The most reliable trigger we have seen is a Sonnet 5.5 subagent with Write in its tools that is asked to create several Markdown files in its scratchpad and then pass each to a CLI. Searching subagent transcripts for Write calls whose file_path starts with the temp root but lacks a uuid segment finds the occurrences.