[BUG] Agent with isolation:worktree reports successful writes but files unchanged on disk (WSL2)
Description
When launching an Agent with isolation: "worktree", the agent reports successful file edits (via Edit tool, Write tool, or sed), but the files on disk remain unchanged. The agent's transcript shows successful tool results, but independent verification (grep, python open().read(), git diff) confirms the files were never modified.
This happened repeatedly (3 separate attempts with 3 different agents) in a single session before diagnosing the root cause.
Environment
- Platform: Linux 6.6.87.2-microsoft-standard-WSL2 (Ubuntu under Windows)
- Claude Code version: 2.1.76
- Model: claude-opus-4-6 (1M context)
Steps to Reproduce
- Launch an Agent with
isolation: "worktree"to modify Python files - Agent uses Edit tool to change field names, add code blocks, etc.
- Agent reports "All changes applied" with specific line numbers
- Agent runs tests — tests pass (but seem to use cached/in-memory state)
- Check the worktree files with
greporpython3 -c "print(open('file').read())"— files are unchanged
Observed Behavior
- Agent transcript shows successful Edit/Write tool calls with no errors
- Agent reports test passes (2,480+ tests)
- Agent summary lists specific line numbers and changes made
git diffshows no modificationsgrepfor the expected new content returns nothing- Python
pathlib.Path.read_text()in a fresh process confirms old content
Expected Behavior
File writes by the worktree agent should persist to the filesystem.
Workaround
Writing via Python script with temp file + os.rename() pattern bypasses the issue:
import pathlib, os
p = pathlib.Path("target_file.py")
text = p.read_text()
text = text.replace("old_content", "new_content")
tmp = p.with_suffix(".py.tmp")
tmp.write_text(text)
os.rename(str(tmp), str(p))
Direct sed -i, Edit tool, and Write tool all fail silently on this WSL2 setup.
Related Issues
- #29110 — Spawned agents: worktree data loss (agents report success, work lost)
- #9458 — Sub-agent Write tool operations don't persist to filesystem
- #12932 — Synchronization problem between worktrees and main repository
- #27044 —
claude --worktreedoes not create a git worktree
Impact
This is a data loss bug that is particularly dangerous because:
- The agent reports success — there is no error signal
- Tests may pass using cached/in-memory state, masking the failure
- The user discovers the loss only when independently verifying
- Multiple retry attempts fail the same way with no feedback
In our case, this caused 3 failed implementation attempts (~15 minutes of agent compute each) before we identified the pattern and switched to the Python temp+rename workaround.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗