Skip to content

[BUG] Cowork silently corrupts files in OneDrive folders with Files-On-Demand #62140

Description

@tlrichar

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Bug report: Cowork silently corrupts files in OneDrive folders with Files-On-Demand

Summary

When a Cowork session has access to a folder that lives in a OneDrive (or any cloud-sync) directory with Files-On-Demand enabled, Cowork's file tools (Read, Edit, Write, and the Linux mount that powers bash) operate on the local placeholder/stub of a file rather than the actual cloud-hydrated content. When Cowork then writes to the file (thinking it has the canonical version), it silently overwrites the user's full cloud copy with the truncated stub plus whatever edits Cowork made. The user loses data silently. No error, no warning, no diff prompt.

Reproduction

  1. Create a file in a OneDrive folder (e.g., C:\Users\me\OneDrive\Documents\Projects\big-file.md) that is >100 KB and has been synced to cloud but evicted from local cache (the "cloud-only" green-circle icon, or any Files-On-Demand state where the file isn't fully kept on disk).
  2. Connect that folder to Cowork.
  3. Have Cowork read or edit the file. From Cowork's perspective, the file appears to be ~130 KB (the typical placeholder size, regardless of true content size). All sections past that byte boundary appear truncated/missing.
  4. Have Cowork write to the file (e.g., via Edit, Write, or cp over the mount).
  5. Result: the actual file on disk is now the truncated content Cowork saw, plus Cowork's edits. The user's full canonical content is destroyed unless OneDrive's version history can be used to roll back.

Evidence from this session

Files destroyed or corrupted by this pattern in one session:

File | Real size (user view) | What Cowork saw | What got written back -- | -- | -- | -- 04-decisions.md | ~158 KB (51 ADRs) | ~114 KB (truncated mid-ADR-040, ADRs 041–045 missing) | If we'd written, would have lost ADRs 041–045. Recovered by reconstructing the lost ADRs from cross-references in other docs. 14-ui-mockups.html | ~258 KB (15 sections) | ~24 KB (only sections 1 + start of 2) | Cowork "rebuilt" sections 3–15 with a different (worse) design language. User had to restore from OneDrive version history. 10-runtime-design.md | ~194 KB (full §1–§10) | ~137 KB (truncated mid-§5.13, missing §5.14–§5.19 + §6–§10) | Multiple times. Eventually resolved by user uploading canonical via chat. Multiple SVG diagrams | ~30 KB | ~30 KB but truncated mid-tag | Render failures (cairosvg couldn't parse); each required patch-via-/tmp workaround.

The unifying signal that distinguishes a real file from a Files-On-Demand placeholder:

bash
$ stat 10-runtime-design.md
  Size: 137377   Blocks: 0       IO Block: 262144 regular file
                        ^^^^^^^^^
                        ZERO BLOCKS on disk despite non-zero Size

Blocks: 0 (or any value much smaller than Size / 4096) is the giveaway. The Windows attribute is FILE_ATTRIBUTE_RECALL_ON_OPEN / FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS.

Suggested mitigations (in order of impact)

  1. Detect Files-On-Demand placeholders before reading. On every file Read from a OneDrive/iCloud/Google Drive folder, check stat for Blocks == 0 && Size > 0. If detected, either (a) force hydration by reading via a Windows API call that resolves the placeholder (the standard Win32 CreateFile/ReadFile does this automatically when called from a non-FILE_FLAG_OPEN_NO_RECALL context), or (b) error out and surface to the user: "This file is currently cloud-only. Click to download for editing, then retry."
  2. Refuse to write to a file that looks dramatically smaller than the version Cowork last saw. A simple guard: if a write is about to replace a file whose previous size was >2× larger, require an explicit confirmation or skip. This single check would have prevented every data-loss incident in this session.
  3. Warn prominently in the docs / agent system prompt. Even just adding to the system prompt "Cloud-sync folders (OneDrive, iCloud, Google Drive) with Files-On-Demand can serve truncated placeholder files; verify with stat ... Blocks before treating large files as canonical" would let agents detect and route around the problem.
  4. Use the OneDrive / iCloud / Google Drive API directly when available. For OneDrive folders, Microsoft Graph API can read the cloud copy regardless of local state. Cowork could detect a OneDrive path and use Graph instead of the local mount for files >N KB.
  5. For the Linux mount specifically: force-hydrate every file in the connected folder on session start, or document clearly that the mount is "best-effort over Files-On-Demand" and provide a fallback path.

Workaround we used (which should not be the user's job)

For every doc edit in this session past the first incident:

  1. User drags the file into chat (uploads to Cowork's /uploads/ folder, which is in AppData — outside OneDrive, no Files-On-Demand layer).
  2. Cowork reads from /uploads/, edits a copy in /outputs/ (also AppData).
  3. User manually opens both files in their editor, copies the patched version, pastes over the OneDrive original.
  4. Cowork verifies indirectly (file size in Windows Explorer matches Cowork's patched-file size).

This is six manual steps per edit on what should be a single-tool-call operation. The user effectively had to operate two file systems and broker between them. They (rightly) called this out as a Cowork-team-should-fix-it problem.

Severity

High. The default Windows + OneDrive configuration (Files-On-Demand on, the default since Windows 10 1709) is the trigger. Anyone using Cowork against a OneDrive project folder is at risk of silent data loss on any large file the agent edits. The user has no way to know it happened until they notice the missing content later.

What Should Happen?

Files should sync from onedrive to shared drive without issue.

Error Messages/Logs

Steps to Reproduce

see original message above

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude 1.8555.2 (a476c3) 2026-05-22T23:04:37.000Z

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions