[BUG] Edit tool silently no-ops on disk while Read returns the edited content (sub-agent worktrees + main session)
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?
Description:
The Edit tool returns success but the change is never written to disk. The Read tool subsequently returns the imagined post-edit content (an in-memory or cached view), but git status / git diff / awk / grep against the file all show the pre-edit content. The discrepancy is silent — no error, no warning.
What Should Happen?
Expected: Edit either persists the change OR errors loudly. Read should reflect on-disk state, not a hypothetical post-edit state.
Actual: Edit silently no-ops; Read returns stale (post-edit-in-memory) content; subsequent Bash commands see the unmodified file.
Frequency: ~8 incidents in one day across multiple sub-agent dispatches (~7 different isolation: "worktree" agents) plus once in the main session. Approx 30-50% hit rate on the first Edit of a session.
Expected: Edit either persists the change OR errors loudly. Read should reflect on-disk state, not a hypothetical post-edit state.
Actual: Edit silently no-ops; Read returns stale (post-edit-in-memory) content; subsequent Bash commands see the unmodified file.
Environment:
- Claude Code CLI 2.1.148
- Model: Opus 4.7 (1M context) — claude-opus-4-7[1m]
- macOS Darwin 25.4.0
- Multiple parallel sub-agents in isolation: "worktree" mode
- Project: Next.js 16 + TypeScript + git worktrees
Notes:
- The cached Read state survives across multiple Read calls in the same session — it's not a transient cache miss.
- The pattern is most prevalent in nested worktrees (sub-agent dispatched from a sub-agent).
- Suspected cause: the Edit tool's persistence layer may not be writing to the actual on-disk file when the agent's cwd is reported as one path but the harness has the file mounted at another (worktree mounting layer).
Error Messages/Logs
Steps to Reproduce
Steps to reproduce:
- Spawn a sub-agent with
Agent({ isolation: "worktree", ... })(also reproduces in the main session occasionally). - Have the agent run
Edit({ file_path: "/absolute/path/to/file.ts", old_string: "X", new_string: "Y" }). - Tool returns "The file ... has been updated successfully."
- Have the agent run
Read({ file_path: "/absolute/path/to/file.ts" })— returns content withY. - Have the agent run
Bash({ command: "git diff -- /absolute/path/to/file.ts" })— diff is empty. - Have the agent run
Bash({ command: "awk 'NR==<line>' /absolute/path/to/file.ts" })— prints the pre-editX.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.148
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗