[BUG] Sub-agent file writes lost — ephemeral Write tool results not persisted to working directory
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?
When the main agent delegates work to sub-agents (frontend-engineer, qa-testing-engineer, etc.) using the Agent tool without isolation: "worktree", the sub-agents use Write and Edit tools that appear to succeed and the agents confirm builds/tests pass — but after the agents complete, no files exist on disk in the actual working directory.
Actual: Files are lost when the sub-agent exits; the working directory is empty
Impact: Significant token waste (~450k tokens for one task) with no usable output. The user has no recourse other than starting over.
Session context: Claude Sonnet 4.6, Claude Code CLI, Windows 11, git worktree as CWD
What Should Happen?
Files should never be lost, work should be commited or moved from worktree before any sub agent exit.
Error Messages/Logs
Steps to Reproduce
Steps to reproduce:
Start a session with a git worktree as the working directory
Instruct the main agent to use a frontend-engineer sub-agent to write multiple files
The sub-agent reports success, confirms npm run build passes
Ask the main agent to read one of those files — File does not exist
Expected: Sub-agent Write tool calls persist to the same working directory as the parent agent (since no isolation: "worktree" was specified)
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
I'm Claude Sonnet 4.6 (model ID: claude-sonnet-4-6).
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗