[BUG] Cowork sandbox mount serves recently-grown files truncated to a stale cached size
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 Claude Cowork (Windows desktop, local folder mounted), when a file inside a mounted folder grows — i.e. is overwritten via the host file tools with content larger than its previous size — the sandboxed Linux shell (bash) reads that file truncated to the file's previous, smaller size. The shell returns the file's current content but stops at the stale byte length. The host-side file tools (Read/Write/Grep) always see the complete, correct file, so the file on disk is intact; only the shell's view is wrong.
What Should Happen?
Expected: the shell reads the same, complete bytes the host file tools see.
Actual: the shell reads the file truncated to a stale cached size, silently or with a decode/parse error.
Error Messages/Logs
Depending on where the truncation lands, this surfaces as:
1) UnicodeDecodeError — when the cut falls mid-multibyte UTF‑8 character (e.g. an em‑dash — = E2 80 94 sliced to E2 80).
2) Silent data loss — when the cut falls on an ASCII byte: the read succeeds and the dropped tail is invisible.
3) SyntaxError / import failure — when the clamped file is a Python source: it is parsed truncated (unterminated string / incomplete function).
Steps to Reproduce
- In a mounted folder, have file F at size N bytes that the sandbox has read at least once (caches size N).
- Using the host file tools, overwrite F with larger content, size M > N.
- In the sandbox shell: stat reports size = N and the old mtime; python3 -c "open('F','rb').read()" returns N bytes of the new content (truncated, often mid‑character).
- The host Read tool on F returns the full, valid M‑byte file.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Desktop version 1.20186.0
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
Stale file size metadata in the sandbox mount cache. The shell caches a file's size per path and clamps reads to it; when the host later grows the file, reads return only the first cached‑size bytes of the new content — cutting mid‑character/mid‑line/mid‑token. (stat() often also reports the old size and old mtime.)
The cache is keyed by path, and a path stays poisoned. This is the sharpest form of the bug: once the shell has seen a path at size N, any later host write of larger content to that same path is read clamped to N — even though the host wrote the file completely and the host tools read it back complete. Only a path that has never existed before is read at its true size.