claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Cowork: device_commit_files reports success on overwrites but the on-disk content lags exactly one commit behind (silent stale write, fresh mtime)

Open GBalunis opened this issue 2 months ago • 29 comments

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?

Summary

When a cloud Cowork session writes back to a file that already exists on the linked device, device_commit_files returns {"written":[path],"rejected":[]}, the file's modification time advances to the moment of the call, and the content on disk is the payload from the previous commit. Committing the identical payload a second time lands it.

Creating a new file is unaffected and correct every time. Only overwrites are affected.

This is a silent data-integrity failure. The session has no signal that anything went wrong, and the file it just "wrote" looks freshly updated to any human or tool inspecting it, because the timestamp is current while the bytes are stale.

Impact

This is worse than a loud failure for two reasons.

  1. The success response is indistinguishable from a real write. An agent that follows the obvious contract, commit and move on, will report work as saved that was not saved.
  2. The timestamp lies in the same direction. A stale file carries the new write's mtime, so ordinary "has this been updated?" checks, sync tools, and human inspection all agree with the false success.

For anyone using a Cowork workspace with recurring update routines, the exposed operations are exactly the common ones: appending to a running log, updating a status line, bumping a version, editing a spec. Every one of those is an overwrite. The drift is invisible until someone reads the file much later.

Workaround

Commit the same payload twice, then stage the file back and grep the content for the intended change. Byte count is a weak check and the timestamp is no check at all. Where possible, do write-heavy work in Claude Code instead, which writes to disk directly and does not use this path. (Confirmed clean by test on the same machine: new file, two Write-tool overwrites, and one Edit-tool in-place edit, each verified from a separate PowerShell process, all four exact with no lag.)

Suggested area to look at

The off-by-one shape suggests something in the commit path is buffering or staging the payload and swapping in the previous one for the overwrite case, since the create case is correct. The mtime being updated from the current call while the bytes come from the prior call points at the metadata write and the content write reading from different sources.

What Should Happen?

After device_commit_files returns written with no rejections, the file on disk should contain the committed payload. If the write cannot be completed, the call should report the path in rejected rather than returning success.

Error Messages/Logs


Steps to Reproduce

Reproduction

Minimal repro, run against a plain local folder (C:\Users\<USER>\Downloads, not OneDrive-backed):

Step Action Committed payload Commit result On disk immediately after
1 device_commit_files (new file) VERSION-A… (43 bytes) written, no rejections 43 bytes, VERSION-A ✅
2 device_commit_files (overwrite) VERSION-B… (82 bytes) written, no rejections 43 bytes, VERSION-A ❌ (mtime advanced)
3 device_commit_files (same payload again) VERSION-B… (82 bytes) written, no rejections 82 bytes, VERSION-B ✅
4 device_commit_files (overwrite) VERSION-C… (89 bytes) written, no rejections 82 bytes, VERSION-B ❌ (mtime advanced)
5 Wait 45 s, re-read, no intervening commit — — 82 bytes, VERSION-B ❌

Payload lengths were chosen to differ, so byte count alone distinguishes the revisions without inspecting content. Content was checked as well via device_stage_files and matched the byte count in every case.

What this rules out

  • Not a read cache. Step 5 waited 45 seconds with no intervening commit and the stale content persisted. device_list_dir and device_stage_files agreed with each other at every step.
  • Not OneDrive. First observed on files under a OneDrive-synced folder, then reproduced identically in C:\Users\<USER>\Downloads, outside OneDrive entirely.
  • Not KB5124008. That update broke the Hyper-V Plan9 shares used by device_bash on this machine (see #92984). The local sandbox shell was completely non-functional throughout this testing while the file bridge kept working, so the two are on different code paths.
  • Not force. Behavior is identical with and without force: true, and with and without expectedMtimeMs.

Observed elsewhere in the same session

Reproduced five separate times across four different files before it was isolated:

  • two markdown files under a OneDrive-synced connected folder (~8 KB and ~65 KB), twice each
  • a .ps1 script file in the same folder
  • the Downloads test file above

In every case the pattern was the same: first commit reports success and leaves the prior revision, second identical commit lands the new content.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

Claude Desktop | 1.49585.0 |

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

Environment

Claude Desktop 1.49585.0
Platform win32 x64
Electron / Node 44.2.0 / 24.20.0
OS Windows 11 25H2, OS Build 26200.9445
Session type Cowork cloud session linked to a desktop device
Model claude-opus-5

Related Issue

This may be related to: https://github.com/anthropics/claude-code/issues/83354

GBalunis avatar Sep 10 '26 22:09 GBalunis

+1, same behavior on my project (Windows, Cowork).

Confirming this on my setup as well:

Editing an existing file in the project via Cowork appears to succeed, but the file on disk reverts to the previous version shortly after. Creating a new file works fine — the problem only shows up on edits to existing files. Watched the write activity with Process Monitor: claude.exe performs two writes to the file in quick succession.

Environment: Windows 10, Claude 1.52386.3 (41896e) 2026-09-11T17:35:10.000Z, Cowork mode, project folder is a local project (not synced via OneDrive or similar)

Skartrek avatar Sep 13 '26 17:09 Skartrek

Follow-up with a stronger confirmation, and a note that this is still present after both the Windows fix and a desktop app update.

Environment now

  • Claude Desktop 1.52386.6 (was 1.49585.0 in the original report)
  • Windows 11 25H2, build 26200.9457 (KB5129195 out-of-band, which fixed the unrelated Plan9 regression)
  • win32 x64, Cowork cloud session linked to a desktop device

Why this run is better evidence. In the original report every read-back went through device_stage_files or device_list_dir, so a skeptic could argue the write landed and the read was stale. That could not be ruled out at the time because the local sandbox shell was down. With the sandbox restored, the file can now be read by a completely separate process on the user's own machine, outside the bridge entirely.

Result

Action Payload Call result cat via device_bash on the same machine
Create new file VERSION-E… (85 bytes) written, no rejections 85 bytes, VERSION-E ✅
Overwrite VERSION-F… (94 bytes) written, no rejections 85 bytes, VERSION-E ❌
Commit identical payload again VERSION-F… (94 bytes) written, no rejections 94 bytes, VERSION-F ✅

The stale content is visible to a shell process on the host filesystem, not just to the bridge's own reader. It is the write that lags, not the read. The one-commit-behind behavior is unchanged from the original report, and creating a new file remains unaffected.

Practical note for anyone hitting this: if device_bash is available, editing the file in place through that shell (a read-modify-write) bypasses the defect entirely and is a better workaround than committing twice. The commit-twice-then-verify dance is only needed when the shell is unavailable, which is exactly the situation the September Plan9 regression created, so for about a week both safe write paths were closed at once.

GBalunis avatar Sep 14 '26 23:09 GBalunis

Confirming this independently - same symptom (success reported on both writes, on-disk content stuck at the earlier version, mtime updates but content doesn't) reproduced today on Windows 11 x64, Desktop app 1.52386.6 (Electron 44.2.0, Node 24.20.0), local SSD (not network/OneDrive).

Minimal repro: two device_commit_files calls to the same path back-to-back, no read in between, no other process touching the file — second write's content never lands, even after waiting 60+ seconds (not a propagation delay, permanent).

Also found a related variant: if a human edits the same file directly on disk between the agent's two writes, the agent's second write can revert the file entirely back to its own first write's content — losing both the human's edit and the agent's second edit.

PensionedITguy avatar Sep 16 '26 18:09 PensionedITguy

Confirming from a different machine (Windows 11 ARM64, build 28000.2954, Claude Desktop 1.49585.0.0, cloud Cowork sessions with the device bridge), with one refinement to the mechanism that may narrow where to look.

Four instances, 7 to 9 September 2026, across three separate projects and four sessions that were not aware of each other. In each, device_commit_files returned {"written":[path],"rejected":[]}, the destination mtime advanced, and the size on disk was the previous commit's (5,301 expected against 5,245 on disk; 33,320 against 28,531 on a .docx; 5,939 against 5,425; 16,615 against 15,729). Files were on OneDrive-synced paths; the thread has already ruled OneDrive out and we have nothing contradicting that.

The key looks like the reused stagedPath, not the overwrite as such. In a control run on the same machine on 9 September, nine files were committed across five calls, each from a container path not previously passed to device_commit_files in that session. All nine landed, verified by re-listing and re-staging. Three of the nine were successive overwrites of the same devicePath, from three different staged paths, and all three landed. Every one of our four failures had reused a stagedPath already sent earlier in the session. So repeated overwrites of one destination are fine when the source path is fresh; repeated sends from one source path are what lag. That is consistent with the one-commit-behind shape in the original report and with the double write seen in Process Monitor, and suggests the staged payload is being cached by source path on the container side and served once stale.

Workaround that has held for us since 9 September: a fresh container path for every commit, even for byte-identical content, and verification by listing the destination's size rather than trusting the response or the mtime. With device_bash available, a read-modify-write in place through the shell bypasses the path entirely, as noted above.

Not tested here: whether fileUuid is affected as well as stagedPath, and whether path alone or path plus size is the key.

samtuominen avatar Sep 17 '26 10:09 samtuominen

Corroborating on a different setup: cloud session linked to a Mac, non-Windows, different model too — so not platform- or model-specific.

Same exact pattern as reported: a commit call returns success (rejected: []), the device mtime updates, but reading the file back immediately shows the previous version's content, not what was just written. Retrying the identical commit fixes it.

In my case it only ever happened on overwrites of an existing path — every write to a brand-new path landed correctly first try. So that lines up with the overwrite-specific theory already in this thread.

One addition: it wasn't always "one version behind" — in one instance it took two retries before the correct content showed up, not just one. So the staleness can apparently lag by more than a single write under some conditions.

Workaround: retry the commit once (didn't need force:true) and it resolves.

lukaszkakol avatar Sep 18 '26 08:09 lukaszkakol

Update: no longer reproducing on Claude Desktop 2.2553.1 (Windows 11, Cowork cloud session linked to desktop device)

I hit this same bug on 2026-09-18/19: overwrites reported written but the file on disk didn't change, in both OneDrive and non-OneDrive folders. force and expectedMtimeMs made no difference. Today I re-ran the A → B → C → A sequence on 2.2553.1 and checked every result on the Windows side with type, not through the bridge's own read-back.

Non-OneDrive folder (C:\Users\<USER>\MSOS), one path, one commit per step:

# commit payload on disk
1 new file A (13 B) A
2 overwrite B (26 B) B
3 overwrite C (38 B) C
4 overwrite (shrink) A (13 B) A (confirmed with type)

OneDrive folder. Here device_stage_files still refuses to read back with nlink > 1, so I wrote four separate files, each stopping at a different step, and checked them all with one type:

file commits lag model predicts on disk
probe_1 A A A
probe_2 A → B A B
probe_3 A → B → C B C
probe_4 A → B → C → A C A

Every overwrite landed on the first call, including a shrink. That fits neither the one-commit-behind pattern nor a hard one-write-per-path limit, so it looks fixed on 2.2553.1. One caveat: I didn't record which app version the earlier failures ran on.

Still present, and probably a separate issue: inside OneDrive-synced folders, device_stage_files refuses files the bridge itself just wrote (file is hardlinked (nlink > 1)). Files edited by hand in the same folder stage fine, and fsutil hardlink list shows only one path on Windows.

macdonbruce-hub avatar Sep 19 '26 19:09 macdonbruce-hub

Not fixed on 2.2553.1, but the trigger is much narrower than this thread has assumed, which explains why it now looks fixed to some of us and not others.

Re-tested today on Claude Desktop 2.2553.1 (Windows 11 25H2, cloud Cowork session linked to a desktop device), same build @macdonbruce-hub reported clean on. Every result below was read with cat through device_bash, a shell process on my own machine, never through the bridge's own read-back. One destination path in a non-OneDrive folder (C:\Users\<USER>\Downloads), five commits.

# container stagedPath payload commit result on disk (cat via device_bash)
1 retest.txt (new file) ALPHA, 66 B written, no rejections 66 B ALPHA ✅
2 retest.txt (same path as #1) BETA, 97 B written, no rejections 66 B ALPHA ❌
3 retest_fresh_01.txt (new path) GAMMA, 121 B written, no rejections 121 B GAMMA ✅
4 retest_fresh_02.txt (new path) DELTA, 27 B (shrink) written, no rejections 27 B DELTA ✅
5 retest_fresh_01.txt (reused, but not consecutively) EPSILON, 141 B written, no rejections 141 B EPSILON ✅

Then a targeted confirmation, two commits back-to-back from one container path:

# container stagedPath payload on disk
6 retest_fresh_02.txt ZETA, 64 B 64 B ZETA ✅
7 retest_fresh_02.txt (same path, immediately after) ETA, 121 B 64 B ZETA ❌

The determinant is committing the same container stagedPath on two consecutive calls. It is not the overwrite. Overwrites are fine, repeatedly, against the same destination, including a shrink (step 4 went 121 B → 27 B and landed). Reusing a source path is also fine as long as something else was committed in between (step 5).

This refines @samtuominen's stagedPath observation, which proposed that any reuse of a staged path was the trigger. Close, but reuse alone is not sufficient: step 5 reused a path and landed. Consecutive reuse is what fails.

It also reconciles @macdonbruce-hub's clean run. Their OneDrive test explicitly used "four separate files, each stopping at a different step," which is precisely the passing condition, so the fix signal there is most likely a false negative rather than a real fix. Worth them re-running with two consecutive commits from one source path before this gets closed.

Better workaround than commit-twice. Write each payload to a new container path before committing it, and never re-commit from a path just used. That made every overwrite land on the first call here. The commit-twice-then-verify advice in the original report still works, but only because the second call happens to follow a different code path or gets a fresh read; writing to a fresh source path avoids the situation entirely. As noted earlier in the thread, if device_bash is available, an in-place read-modify-write through that shell bypasses the bridge completely and remains the safest option.

Suggested area to look at, updated. The consecutive-only shape points at a single-slot or last-key cache of the staged payload keyed by source path, where a second lookup on the same key inside one window returns the prior contents. That would explain all seven results above, the correct create case, and why a shrink lands normally when the source path is fresh.

GBalunis avatar Sep 19 '26 22:09 GBalunis

Correction to my earlier comment: @GBalunis is right, my clean run was a false negative. Every commit in it used a different container stagedPath, which is the passing condition.

Re-tested on 2.2553.1, non-OneDrive folder: committed CONSEC-1 (9 B) from same.txt, rewrote same.txt to a 32 B payload, and committed it again from the same path. The response was written, no rejections. The disk still holds CONSEC-1, 9 B. Not fixed. Reusing a stagedPath on consecutive calls reproduces it.

Using a fresh container path for every commit avoids it. Every overwrite landed first time that way, including in OneDrive folders.

macdonbruce-hub avatar Sep 20 '26 00:09 macdonbruce-hub

Confirming this on Linux desktop, with a minimal reproducer and two details that narrow the cause.

Environment

  • Claude Desktop 2.2553.1, Electron 44.2.0, Node 24.20.0, platform linux/x64
  • Host: Fedora 44 atomic (Bazzite DX), GNOME/Wayland
  • App runs inside an Ubuntu 24.04 Distrobox container
  • Workspace VM reached by device_bash: local KVM guest, Ubuntu 22.04, systemd-detect-virt: kvm
  • Connected folder arrives over FUSE

The existing report reads as macOS/cloud-session; this is a Linux desktop with a local KVM workspace VM, so the bug isn't platform- or transport-specific.

Minimal reproducer

One 11-byte file, one variable changed per step:

container: echo VERSION-ONE > /mnt/user-data/outputs/probe-force.md   # md5 02870e9d…
commit     probe-force.md -> device:probe-force.md                     # {"written":[…],"rejected":[]}

container: echo VERSION-TWO > /mnt/user-data/outputs/probe-force.md   # md5 90934ca0…
commit     probe-force.md -> device:probe-force.md   force=true        # {"written":[…],"rejected":[]}

device:    cat probe-force.md   ->  VERSION-ONE
           md5sum               ->  02870e9d…      (the FIRST version)

Second commit reports success, the device file's mtime advances, contents do not.

Observed the same thing at scale first, on a 14 KB document:

md5 bytes
Container (source of truth) 01b2c6291edc2e983f6b8cf1f90a3fcc 14,403
Device, after "successful" 2nd commit 6d51a70ca0eed90bea91846450ba6c0d 13,623

Two findings that narrow it

1. force: true does not help. It governs the expectedMtimeMs guard only; it does not invalidate whatever is cached. Both calls above used force=true on the second commit and still landed VERSION-ONE.

2. The cache is keyed on stagedPath, not devicePath. Committing the same edited content from a fresh stagedPath to the same devicePath lands byte-exactly — verified md5 f66a416dd2f0149bf41854c0c21fc861, 16,987 bytes identical on both sides. A fresh-path → fresh-path control also transfers exactly (md5 05010a15e98eeb92d0803911c3a9a8ca, 14,438 bytes).

So the transfer path itself is sound. It's specifically the reuse of an already-committed stagedPath that goes stale, which is consistent with a snapshot being taken at first commit and reused afterwards, while the write still executes from the cached bytes.

Why this is worse than it looks

There is no error and no rejection. The caller is told it wrote, and the mtime on disk agrees. The expectedMtimeMs guard doesn't catch it either — that guards against the user's edits, not this. Any agent that commits, edits, and re-commits within a session leaves the user with silently outdated files while believing otherwise, and the freshened mtime actively disguises it.

I found this while having Claude write a report into a connected folder. The final document on disk was two revisions behind what the session believed it had written, and nothing in the tool output indicated a problem.

Workaround

Write each revision to a new stagedPath and commit that. Don't reach for force: true — it doesn't address this.

Until it's fixed, verifying with md5sum over device_bash after every commit seems like the only reliable check. Treating {"rejected":[]} as "the call was accepted" rather than "the bytes are on disk" would be a safer default for tooling built on this.

RadicalZephyr avatar Sep 20 '26 15:09 RadicalZephyr

Independent reproduction, 2026-09-23, Windows 11, with one addition that makes this worse than a stale write: the stale re-send overwrites host-side edits made between the two commits, so it destroys data that never went through the bridge at all.

Setup

Two sessions on the same machine and folder at the same time: a Cowork session writing through device_commit_files and reading through device_bash, and a Claude Code CLI session on the host reading and writing the files directly. Every host read below is from the CLI session (cat, stat, md5sum), so it is independent of the bridge. All files are fresh scratch files in a plain local folder, not OneDrive.

Sequence

# Actor Action Host file afterwards (read from the CLI)
1 Cowork device_commit_files creates mt-1.txt (MARKER-A) 108 B, c8aa4227…, MARKER-A ✅
2 Cowork reads mt-1.txt through device_bash sees 108 B, MARKER-A ✅
3 Host (CLI) appends a line MARKER-B to mt-1.txt directly on disk 144 B, 86a0b2ee…, MARKER-A + MARKER-B
4 Host (CLI) copies mt-1.txt to mt-2.txt 144 B, identical
5 Cowork reads mt-1.txt and mt-2.txt through device_bash sees 144 B, 86a0b2ee… on both ✅ (host change visible, no stale read)
6 Cowork device_commit_files overwrites mt-1.txt with new content (MARKER-D), reusing the staged name from step 1. Returns written, no rejections 108 B, c8aa4227…, MARKER-A only, mtime advanced to the time of the call ❌

Reproduced on the first attempt.

What this adds to the original report

  1. Data loss, not just a lagging write. After step 6 the host file is the step-1 payload. The MARKER-D payload never landed, and the host-side MARKER-B edit from step 3 is gone too. It only survives because it had been copied to mt-2.txt beforehand. In practice this looks like the Cowork session "reverting" someone else's edit: the Cowork session edits a file, a human or another tool edits the same file on disk, and the next Cowork overwrite silently restores the Cowork session's earlier upload over both.
  2. The read side is honest here. At every step the Cowork session's device_bash read matched the independent host read byte for byte, including step 5, where the host had changed a file Cowork had already read. So this is not the stale-mount-read behaviour in #38993. The fault is in the commit path.
  3. It is consistent with the original analysis: the bytes that land are the previous device_commit_files payload for that path (step 1), and the mtime comes from the current call. Creating a new file from the Cowork side was correct every time (step 1, plus a separate device_bash write to a third file, both byte-exact on the host).

Workaround we are using

Use a staged name that has never been used before for every device_commit_files call, and confirm the result from an independent host process. Reading back through device_bash does confirm what is on disk, but on its own it cannot tell you that an intervening host edit was destroyed.

Environment

  • Claude Desktop 2.2553.13
  • Windows 11 25H2, build 26200.9457
  • Cowork session linked to a desktop device; the CLI session is Claude Code on the same machine

Vicellia avatar Sep 23 '26 16:09 Vicellia

Confirming @Vicellia's destructive finding, on Claude Desktop 2.7032.0 (Electron 44.4.3, Node 24.21.0), which is newer than any build reported in this thread so far. Windows 11 25H2, cloud Cowork session linked to a desktop device, plain local folder, not OneDrive.

I want to flag something about my own earlier comment first: the seven-run test I posted could not have detected this, and neither could any of the reproductions above it. In every failing run we had recorded, the destination already held the old payload, so "the new write didn't land" and "the old bytes were re-written over whatever is there" produce an identical observation. Separating them requires changing the file between the two commits. That is what @Vicellia did, and it is the single most important addition to this thread.

Reproduction

The host edit below was made through device_bash, a shell on the same machine, so it never passed through the bridge. Every read is from that shell.

# Actor Action On disk afterwards
1 bridge device_commit_files creates the file, PAYLOAD-A 72 B, md5 0f5d3227…
2 host device_bash appends a MARKER-HOST line 155 B, md5 472a3d78…
3 bridge commit PAYLOAD-C (118 B) from the same container path as step 1, force: true. Returns written, rejected: [] 72 B, md5 0f5d3227…

After step 3 the file is byte-identical to the step-1 payload. PAYLOAD-C never landed, and the host edit from step 2 is gone. It existed only on that disk. Reproduced on the first attempt.

So this is not a lagging or skipped write. It is an active write of a cached earlier payload over current contents, and it will erase anything any other actor put there in the meantime: a person in an editor, a Claude Code session, a script, another tool.

The fresh-path rule does hold against it

Immediately after, as a control on the same file and same session:

# Actor Action On disk afterwards
4 host device_bash appends MARKER-HOST-2 160 B, md5 5eda9a90…
5 bridge commit PAYLOAD-F (138 B) from a container path never committed from before 138 B, md5 3fc39df9… ✅

Exactly the intended bytes. So a never-before-committed stagedPath per call avoids both the stale write and the destructive rewrite. That remains the workaround, and it is now a data-safety measure rather than a convenience.

Two consequences for advice already in this thread

1. "Commit the same payload twice" is now actively unsafe and should be retracted. It appears in the original report and in several comments, mine included. Under the destructive model, the first of those two calls is the one that overwrites other people's work. It then "succeeds" on the second call, so the operator sees a good outcome and never learns anything was lost. Anyone still following that advice should switch to a fresh staged path.

2. Read-back verification cannot detect this class of loss. Reading the destination after a commit tells you whether your payload landed. When it shows the older content, the natural reading is "stale write, send it again" — which is exactly wrong if that older content arrived by overwriting someone's edit. The honest read is honest about the current bytes and silent about what they replaced. Hashing the destination before committing over it is the only check that catches it, and that is a lot to ask of every caller.

Suggested handling

Beyond the fix itself, two things would reduce the blast radius for anyone on an affected build:

  • Invalidate the staged-payload cache on stagedPath reuse, or key it on content rather than path. A content hash in the commit response would also let callers verify cheaply.
  • Treat {"written":[...],"rejected":[]} as "accepted", not "the bytes are on disk", in anything built on this tool. Several of us independently arrived at that same conclusion.

Given that this can silently destroy user data that never went through the bridge, and that it is present on 2.7032.0, I think it's worth a severity bump and a note in the release channel until a fix ships.

GBalunis avatar Sep 23 '26 17:09 GBalunis

Bug report: Cowork device_commit_files silently writes the PREVIOUS commit's content when the same output path is reused

Severity: high — silent data loss / stale overwrite. The tool reports success and the expectedMtimeMs guard does not catch it. Reproducibility: deterministic (3 of 3 in a controlled test, plus 3 earlier real incidents). Status of root cause: the stale content is not stored on the user's machine. The fault is upstream of the local disk write.

Environment

  • Claude desktop for Windows 2.7032.0 (Claude_2.7032.0.0_x64__pzs8sxrjxfjjc, MSIX package)
  • Bundled Claude Code 2.1.280
  • Windows 11 Pro 10.0.26200
  • A Cowork (cloud) chat linked to the user's computer over the device bridge; a separate local Claude Code session runs on the same machine
  • The app's remote-session-spaces.json lists 15 Cowork sessions; the 6 entries inspected are all registered to the same single folder, C:\Users\Bob\Downloads\Claude.ai (no per-project registration differs in what was inspected)
  • Target repo is a git working copy under C:\Users\Bob\Downloads\Claude.ai\GitHub\<repo>\
  • All times below are local (EDT, UTC-4) on 2026-09-24

Symptom

The Cowork chat edits a file at a fixed container output path (e.g. /mnt/user-data/outputs/<name>), then calls device_commit_files with that path and expectedMtimeMs. The call returns written: [...], rejected: []. An immediate re-stage of the file from the device shows content from the PREVIOUS commit to that same output path, not the content just sent. The container-side hash of the file at commit time is correct; the bytes that land on the device differ.

Deterministic reproduction (A/B/C, throwaway untracked file)

Same reused container path /mnt/user-data/outputs/lag-test.txt for all three commits, target docs/lag-test.txt:

Commit sent Reported by tool Read back from device Local watcher: content hash written (SHA-256, first 10)
1st: A (new file) written, 0 rejected A 06F961B802 = A\n
2nd: B (guard = mtime from commit 1's stage) written, 0 rejected A 06F961B802 = A\n again
3rd: C (guard = mtime from commit 2's stage) written, 0 rejected B C0CDE77FA8 = B\n

A stable one-commit lag (N-1), not zero and not two. The first write to a brand-new path is correct because there is no previous revision to serve. Writing each commit under a brand-new unique filename avoided the problem in a separate test (a real install.sh + VERSION change landed correctly and held).

Machine-side evidence (local file-system watcher, independent of the chat's account)

A FileSystemWatcher on the target folder, logging every event with a millisecond timestamp and content hash, captured each bad write:

  • One atomic write per commit, no second write, no later revert. Signature: create .<name>.<PID>.<random>.tmp in the target folder → delete the old file → rename the temp file over it. The file's modification time is set to the device mtime the chat later reports.
  • The writer is the Claude desktop app's main process. The PID embedded in the temp-file name resolved to Claude.exe (the main process, parent = the app launcher), not a helper and not Claude Code.
  • Fresh process, same behavior. After every Claude process was killed and the app restarted, the next test was written by the NEW main process (PID 20804, started 4:53:37 PM) with the same signature and the same one-commit lag. So the stale revision is not held in the previous process's memory.
  • No local copy of the stale content exists. A search of the app's data folders, package cache, temp and Downloads (files modified since 4:20 PM) for the exact text of an earlier payload found no hits in UTF-8 or UTF-16. (Compressed cache formats are not fully excluded.)
  • Git is not involved. No .git\index or HEAD activity at any of the write moments; the reflog shows only the user's own commits.

Ruled out

Windows Controlled Folder Access (off) and Defender events; OneDrive (folder is outside it, files carry plain Archive attributes, no placeholders); a git GUI or editor; git hooks / fsmonitor; scheduled tasks or cron; other Claude Code sessions (none exist, including archived); another writer at the time of the bad writes; an external process reverting edits (a manual edit to a tracked file made by the local session persisted untouched for 60 seconds with an unchanged mtime).

Timeline of incidents (local time)

Time Event What landed
4:10:22–23 PM docs edit committed (2 files, one call) earlier version of the same file (before the previous good edit)
4:27:09 PM install.sh + VERSION 0.2.4 committed previous content (0.2.3)
4:49:56 PM controlled test 1, reused path content from before the prior commit at that path
4:55:18 PM controlled test 2 (after full app restart) test 1's intended payload (exactly one commit behind)
5:00:01–18 PM A/B/C test A, A, B (one commit behind, each time)

What is not known

  • Why this chat is affected when the same tool worked without this behavior in at least six other Cowork chats used against other repos. (Those chats may simply have used different output filenames per delivery; that is unverified.)
  • Where the previous revision is stored (a server-side outputs store, a relay, or an app-side cache in a form the search missed).
  • Whether the lag is keyed by container path, by filename, or by (chat, path).

Impact

The expectedMtimeMs guard is meant to prevent clobbering newer edits, but here the write itself carries older bytes, and the tool reports success. A workflow that trusts written can overwrite a correct file with stale content without any error. In this case a git working tree was protected only because the local session diffed every delivery against HEAD before committing.

Workaround in use

  1. Commit each write from a brand-new unique output filename (never reuse a path across commits).
  2. Hash-verify the file from the device immediately after every write; do not trust the written response.
  3. On the receiving side, diff the working tree against HEAD before committing anything.

Suggested checks for the maintainers

  • Does the bridge resolve an output file by path/name against a cached upload when a newer upload of that name exists?
  • Is the read of the container file racing the upload of the just-edited file, returning the prior revision (consistent with a strict N-1 lag)?
  • Why does the rejected list stay empty and the mtime guard pass while the content is a prior revision?

bdelima avatar Sep 24 '26 22:09 bdelima

Both cases clean on 2.9939.2 (Electron 44.4.3, Node 24.21.0; Windows 11 25H2, Cowork cloud session linked to a desktop device). Newer than the 2.7032.0 builds reported above. Every result below was graded by type in a Windows shell, not by bridge read-back.

1. Stale write — one destination, three commits from the same container stagedPath:

# payload from reused stagedPath on disk (type)
1 RETEST-1, 9 B (new file) 9 B ✅
2 RETEST-2, 34 B 34 B ✅
3 RETEST-3, 45 B 45 B ✅

An affected build gives 9 B at step 2 and 34 B at step 3. This is the same consecutive-reuse condition @GBalunis isolated.

2. Destructive case (@Vicellia's variant), the one my earlier false negative couldn't see:

# actor action on disk
1 bridge commit PAYLOAD-A, 41 B 41 B
2 host user appends MARKER-HOST in Notepad 63 B (bridge read-back agreed)
3 bridge commit PAYLOAD-C, 58 B, from the step-1 container path, force: true 58 B PAYLOAD-C ✅

No revert to PAYLOAD-A. The host edit was replaced only because the commit was meant to replace the file.

Caveat: one machine, one app session. I'm keeping the fresh-stagedPath rule as a default regardless, since it costs nothing and is the known-good path on affected builds. But if others can confirm on 2.9939.x, this may be fixed somewhere between 2.7032.0 and 2.9939.2.

macdonbruce-hub avatar Sep 27 '26 17:09 macdonbruce-hub

I've confirmed the bug is still there in v2.9939.2.

bdelima avatar Sep 28 '26 00:09 bdelima

Tiebreaker on 2.9939.x: still broken. @bdelima is right. Both cases reproduce on 2.9939.4 (Electron 44.4.3, Node 24.21.0), Windows 11 25H2, cloud Cowork session linked to a desktop device, plain local folder. Every read below is cat + md5sum from device_bash, a shell on the same machine, never the bridge's read-back.

1. Stale write — one destination, three commits from the same container stagedPath:

# payload sent on disk
1 RETEST-1, 9 B (new file) 9 B ✅
2 RETEST-2, 60 B 9 B ❌
3 RETEST-3, 92 B 60 B ❌

An exact N-1 lag, matching @bdelima's A/B/C table.

2. Destructive variant:

# actor action on disk
1 bridge commit PAYLOAD-A, 41 B, md5 897d659a… 41 B
2 host device_bash appends MARKER-HOST 114 B, md5 85514b5e…
3 bridge commit PAYLOAD-C, 81 B, from the step-1 container path, force: true. Returns written, rejected: [] 41 B, md5 897d659a… ❌

The host edit is erased and the file is byte-identical to the step-1 payload.

On @macdonbruce-hub's clean 2.9939.2 run: worth noting this thread has now produced three "looks fixed" reports, and all three were tests that used a fresh container path per step, which is the known passing condition. The only reports that reproduce are the ones that reuse a path on consecutive calls. I'd treat any future clean result as unconfirmed unless the test explicitly reuses one stagedPath across two back-to-back commits, ideally with the payload lengths stated so the N-1 lag is visible.

@bdelima's FileSystemWatcher evidence is the most useful thing added here and deserves a second look from maintainers. It establishes that there is exactly one atomic write per commit, performed by the desktop app's main process, with no second write and no later revert; that the stale content is not present anywhere on the local disk, in app data, cache, or temp; and that a full app restart with a fresh PID reproduces the same lag. Taken together that puts the previous revision upstream of the device — a server-side outputs store or the relay — rather than in any local cache. That also explains why nothing user-side helps: no restart, no cache clear, no machine change.

Practical consequence for anyone reading this thread for mitigation: the fresh-stagedPath rule is not a cache-flushing trick, it is the only lever available on the client side. Keep using it, keep verifying from an independent process, and for git-tracked destinations diff against HEAD before committing, which is the one place a stale write gets caught for free.

Thanks for the data-loss label. Given that it is still reproducing on the newest build in this thread, a note in the release channel would probably save people some silent damage in the meantime.

GBalunis avatar Sep 29 '26 01:09 GBalunis

Confirming on Windows with Claude Desktop 2.9939.4 (a166d8), built 2026-09-27.

Setup: cloud session linked to a Windows computer; files prepared in the container and written with device_commit_files, then verified with device_list_dir and device_stage_files.

What happened (2026-09-29), all three commits targeting the same devicePath, from the same stagedPath:

  1. Commit A: a batch of 7 files, target file included → correct on disk.
  2. Commit B: a batch of 5 files, same stagedPath for the target, other files committed before it in the same batch → correct on disk (104,483 bytes, verified byte-for-byte).
  3. Commit C: single file, same stagedPath, ~6 minutes after B, no other commit in between. Response: {"written":[path],"rejected":[]}. device_list_dir shows mtime advanced, but size still 104,483 bytes; the payload was 104,413 bytes. The disk held payload B, i.e. one commit behind.
  4. Retry of C with force: true → correct (104,413 bytes, verified byte-for-byte).

This fits the pattern described above: reusing the same stagedPath is fine when other paths are committed in between (A→B), and stale when the reuse is back-to-back (B→C). expectedMtimeMs did not catch it, since the mtime check passed before the write.

It is the third time this has happened in this project. We now use a unique stagedPath per commit and verify the size with device_list_dir after every write.

FangAlpha avatar Sep 29 '26 21:09 FangAlpha

Edited 2026-09-30: added two controlled runs. They replace my earlier size result, which was wrong.

Adding a data point that may widen the trigger, plus some mount evidence. I first hit this on 2026-09-09.

A prior commit is not required. On 2026-09-29 I wrote a source path, rewrote it ten seconds later, and committed it once, within two seconds of the rewrite. The destination received the first draft. The local file held the final draft, and its SHA-256 matched what I later committed successfully from a fresh path. So the fault is not limited to two consecutive commits from the same stagedPath. It also fires when a path is rewritten before its first commit, which is hard to square with a cache filled at commit time, since there was no earlier commit to fill it.

Controls the same day. Eleven other source paths committed that day passed, at gaps of two to sixteen seconds between last touch and commit. A write-back delay alone does not explain the failure.

The container's local view is coherent. Write tool, Edit tool and bash agreed at 80 bytes and at 36,000 bytes, immediately and after 20 to 30 seconds. I could not reproduce #55877. device_stage_files also overwrote an existing container copy correctly, so I could not reproduce #83354 either.

Mount observation. The outputs mount is an rclone FUSE mount (vfs_cache_mode = full, cache_duration_s = 3600) whose remote is the filestore service. My working guess is that the commit reads a remote copy of its source rather than the local view. A path already uploaded and then rewritten would then send the old upload. The runs below support this. I cannot list the remote copy without the mount's own auth token, so I have not confirmed it. Could someone on the team say which copy device_commit_files reads?

Controlled runs, 2026-09-30. A scratch folder on the linked Linux machine, a fresh destination per commit. Every result was read with sha256sum by a separate process on the host, and again by staging back. The two agreed every time. Each arm ran once.

Run 1:

Arm Source path Size Rewrite to landing Landed
A written once 30 KB n/a correct
B rewritten 10 s after first write, committed at once 30 KB 3.4 s first draft ❌
C as B, then a 60 s wait 30 KB 63.4 s correct
D consecutive reuse 30 KB 3.4 s stale ❌
E consecutive reuse 100 B 3.0 s stale ❌
F reused, another commit in between 30 KB 3.0 s stale ❌
G reused, another commit in between 100 B 2.8 s stale ❌

Run 2:

Arm Source path Size Rewrite to landing Landed
H written once, committed at once 30 KB n/a correct
I written once, committed at once 100 B n/a correct
J rewritten, then a 10 s wait 30 KB 13.3 s correct
K rewritten, then a 20 s wait 30 KB 22.8 s correct

What this suggests. In my runs the variable is time since the source was rewritten, not consecutive reuse and not size. A commit landing within about 3 s of a rewrite sent the previous version, 6 of 6, whether or not another commit came between. Given 10 s or more, 3 of 3 landed. A first write was always correct, 7 of 7, including two committed at once. Commits of a new path took about 7 s to land, and commits of a rewritten path about 3 s, stale. That looks like the commit waiting for an upload on a new path but taking whatever copy already exists for a rewritten one, which would fit rclone's default 5 s write-back. That is inference from single runs. GBalunis's step 5 may have passed simply because more time passed between rewrite and commit.

Workaround. One fresh source path per commit, never rewritten, committed once, with a SHA-256 read-back of the destination. That has been my mitigation since 2026-09-15, and the failure above was on the one path where I broke it. force: true made no difference in my tests.

+1 to returning a content hash in the written result. It would make this class of silent stale write loud.

Environment: Cowork cloud session linked to a Linux Mint 22.3 Cinnamon (x64) desktop, Claude Desktop 2.7032.0.

aitkeni54 avatar Sep 30 '26 11:09 aitkeni54

Correcting my own earlier comment: the consecutive-reuse trigger I posted was wrong, and @aitkeni54's timing model is right. I reproduced both halves of their result today on Claude Desktop 2.31226.1 (Windows 11 25H2, cloud Cowork session linked to a desktop device). Every read is md5sum from device_bash, a shell on the same machine.

Half 1 — a prior commit is not required. A brand-new container path, never committed from:

time action bytes / md5
16:23:04 write DRAFT-1 to the new path 93 B, 057980c4…
16:23:23 rewrite the same path to DRAFT-2 125 B, d679508e…
16:23:2x first-ever commit from that path → on disk: 93 B, 057980c4… ❌

The destination received DRAFT-1. There was no earlier commit from that path, so there was no cache for an earlier commit to fill. That alone falsifies the consecutive-reuse model I proposed.

Half 2 — consecutive reuse with a delay is fine. Same path, immediately after, no intervening commit from any other path:

time action bytes / md5
16:23:51 rewrite to DRAFT-3 181 B, 9eb33153…
16:24:13 commit, 22 s after the rewrite → on disk: 181 B, 9eb33153… ✅

Correct, on a back-to-back reuse of the same stagedPath. Under my model that should have been stale.

Why I got it wrong, in case it saves someone else the trouble. In every test I ran, the two candidate causes moved together: my consecutive-reuse cases were always write-then-commit with no gap, and my one passing non-consecutive case happened to have a full commit-and-verify round trip in between, which bought it ten-plus seconds. I named the variable I was looking at rather than the one doing the work. Re-reading the thread with the timing model, every result in it fits, including the three "looks fixed" reports, which were paced tests with time between steps.

The practical consequence matters, because the workaround most of us converged on has a hole. "Use a fresh stagedPath for every commit" does not protect a fresh path that is drafted and then revised in place before its first commit, which is an extremely common agent pattern. @aitkeni54's formulation is the correct one and I'd suggest the thread adopt it verbatim:

One fresh source path per commit, never rewritten, committed once, with a hash read-back of the destination.

If a staged file does get rewritten, waiting ~20 s before committing made it land in 1 of 1 here and 3 of 3 in their runs.

The destructive variant I reported on 2.7032.0 is unaffected by this correction. It still destroys host-side edits; only the trigger description changes.

For maintainers: @aitkeni54's question is the one worth answering — which copy of the source does device_commit_files read, the mount's local view or the remote? Their rclone FUSE observation (vfs_cache_mode=full, ~5 s write-back) would explain the entire thread, including why a first write of a never-rewritten path is always correct and why the lag looks like N-1 under fast automation. Seconding the request for a content hash in the written response; it would turn every case in this thread from silent into loud.

GBalunis avatar Oct 11 '26 18:10 GBalunis

Confirming this on Claude desktop 2.31226.1.0 (Microsoft Store / MSIX), Claude Code 2.1.295, Windows 11 build 10.0.26300.9457, folder on a local NTFS SSD (no OneDrive / Google Drive / Dropbox, Defender Controlled Folder Access off). Same symptom: device_commit_files returns {"written":[...],"rejected":[]}, the mtime is updated, but the file on disk holds the PREVIOUS staged version.

Extra data from a systematic test. A watcher on the PC logged every change of (SHA-256, size) with timestamps (polling every 1-2 s), and the session reported the SHA-256 and size of each prepared file.

Delivered content is exactly one version behind. Same cloud file rewritten 3 times with the commit called right after preparation: the disk received, in order, the version prepared 10 s before the first commit, then the first version, then the second. The third version never reached the disk. All versions were 30 bytes, so a size check alone cannot detect it.

Delay between the end of preparation and the commit call (existing file rewritten): 0-2 s: 5 stale out of 5 (including an identical re-commit 2 s later, which did not fix it); 3 s: 1 stale out of 3; 5 s: 9 out of 9 correct; 8 s: 3 out of 3; 12 s: 3 out of 3; 15 s: 6 out of 6; 20 s: 2 out of 2.

Brand-new files were always correct (including 3 new files of 200 KB, 1 MB and 5 MB committed in one call).

Large files: 12 rewrites of 200 KB, 1 MB and 5 MB files at 5 s and 15 s delays all matched the announced SHA-256 and exact size, with no truncation and no NUL padding.

The same cloud path reused with a 20 s wait delivered the correct content, so reusing the staged path alone does not seem to be the trigger; the time between preparation and commit does.

Workaround in use: wait at least 15 s between the end of preparation and the commit for any existing file, and verify SHA-256 and size on the PC afterwards. Small sample (a few cases per delay) and I cannot see the cloud side.

Request (same as above): please return the size and SHA-256 of the bytes actually written in the response, or an error when the staged content is stale.

ElMinouh avatar Oct 12 '26 10:10 ElMinouh

Independent reproduction on a different setup, plus one variable the thread hasn't isolated yet: delay between the container-side edit and the commit.

Environment: cloud Cowork session (Sonnet 5.5) linked to a Windows 11 Enterprise 25H2 device (build 26200), Claude Desktop 2.31226.0. Tested 2026-10-12. This is a single reproduction session with small samples, so treat the numbers as indicative.

What I saw. Same silent pattern as above: device_commit_files returns written, rejected: [], the mtime advances, but the device file holds the previous content. Detected via SHA-256 of the source vs a re-staged copy, and via head/cat through device_bash.

What may be new: the outcome depended on how long I waited between the container-side Edit and the commit. In every cycle the commit source was the same container path (/mnt/user-data/outputs/<file>):

Delay edit → commit Result on device
first commit of a new path correct
~0 s (same path reused) previous content (stale)
~5 s previous content (stale), 1 run
7 s (2 runs), 8 s (3 runs), 10 s (1 run) correct
committing the unchanged source again ~13 s after a stale commit correct

So reusing the same source path was not sufficient to trigger it in my runs, and the "commit twice" workaround may work simply because more time has passed. This doesn't fit a pure "consecutive reuse of stagedPath" model, but it doesn't fit pure timing either (see Vicellia's report, where the destructive overwrite happened with a host edit in between). One experiment could separate the two: same stagedPath, same payload sequence, vary only the delay between writing the container file and committing (0 s vs ~10 s). I won't be repeating the tests, so this is left for anyone who wants to check it.

Other observations (same session, one run each):

  1. expectedMtimeMs without force rejected a commit when I had modified the device file via device_bash after staging. So the destructive overwrite of host edits reported above is probably limited to commits with force: true or without expectedMtimeMs (omitting it overwrites silently). The guard does not catch the stale-bytes case itself.
  2. The transient nlink = 2 that makes device_stage_files refuse a file ("hardlinked") for ~9–15 s after a write also appears after plain shell writes (>>, temp+mv, Python os.replace), not only after commits. Re-staging is therefore an unreliable way to verify a commit right after it.
  3. Verification via device_bash (cat/hash) showed the actual on-disk state immediately.
  4. 10 shell writes through device_bash (append, temp+mv, os.replace) landed correctly in 0.07–0.6 s total. A safe stage → edit → wait → commit → verify cycle took ~15–16 s. If device_bash is available, in-place writes bypass the bridge, as others noted, and are two orders of magnitude faster.

What held for me: pass expectedMtimeMs from a fresh stage, never force, wait ≥ 8 s after the container edit (or use a never-used stagedPath), and always verify with a hash through device_bash. Not tested: concurrent writers, large files via the commit path.

rstribrn avatar Oct 13 '26 08:10 rstribrn