Repository navigation
[BUG] Sub-agents claim successful file creation but files don't persist to filesystem #4462
Description
[BUG] Sub-agents claim successful file creation but files don't persist to filesystem
Summary
Sub-agents spawned via the Task tool report successful file creation using Write/Edit/MultiEdit tools, but the files do not actually persist to the filesystem. This creates a critical inconsistency where agents confirm success but no file changes occur.
Environment
- Claude Code Version: 1.0.61
- Platform: macOS (Darwin 24.5.0)
- Node Version: v24.4.1
- Project Type: Next.js with TypeScript
Bug Description
Expected Behavior
When a sub-agent uses the Write tool to create a file, the file should be created on the filesystem and be visible in directory listings.
Actual Behavior
Sub-agents report successful file creation with detailed confirmation messages, but external verification shows no files were created. The agent's response often includes mock directory listings showing the file exists, but filesystem checks confirm it doesn't.
Reproduction Steps
-
Test with project-level agent:
Task(subagent_type="project-business-analyst", prompt="Create a test file called 'agent-file-test.md' with basic content")
-
Agent reports success with message like:
I have successfully created the test file `/path/to/agent-file-test.md` -
Verify file doesn't exist:
ls -la | grep agent-file-test find . -name "*agent*test*" 2>/dev/null # Both return no results
-
Control test - Direct Write tool works:
Write(file_path="/path/to/control-test.md", content="test")
✅ File successfully created and persists
Systematic Test Results
| Test Method | Agent Type | File Creation Claim | File Actually Exists |
|---|---|---|---|
| Task tool | project-business-analyst | ✅ Success | ❌ No file |
| Task tool | business-analyst-developer | ✅ Success | ❌ No file |
| Task tool | business-writer | ✅ Success | ❌ No file |
| Direct Write | Main Claude instance | ✅ Success | ✅ File exists |
Technical Analysis
Agent Tool Configuration
Tested agents have proper Write tool access:
tools: ["Read", "Grep", "Glob", "LS", "TodoWrite", "Edit", "MultiEdit", "Write"]Observed Pattern
- First invocation: Occasionally works (inconsistent)
- Subsequent invocations: Consistently fail to persist files
- Agent feedback: Always reports success regardless of actual outcome
- Main Claude instance: Direct tool usage always works correctly
Impact Assessment
This issue severely impacts:
- Multi-agent workflows: Cannot rely on file handoffs between agents
- Documentation automation: Agents cannot generate actual documentation files
- Code generation: File-based code generation workflows fail silently
- User experience: Creates mistrust due to success claims vs. reality mismatch
Possible Root Causes
- Execution Context Isolation: Sub-agents may operate in temporary/sandboxed contexts
- Session Lifecycle: Sub-agent sessions may be cleaned up before file operations complete
- Permission Model: Different filesystem access between main instance and sub-agents
- Tool Implementation: Write tool may behave differently in sub-agent contexts
Related Issues
- Sub-Agent Task Tool Not Exposed When Launching Nested Agents #4182 - Sub-Agent Task Tool limitations
- Task tool lacks transparency - missing visibility into sub-tool calls and external requests #3978 - Task tool transparency issues
- [BUG] When Claude Code is running a Task tool and a sub-agent is processing something, something happens and Claude Code crashes. #3408 - Task tool crash scenarios
Current Workarounds
- Use direct tool calls instead of Task tool for file operations
- Always verify file creation externally after sub-agent operations
- Avoid sub-agents for critical file operations
Additional Context
This was discovered during systematic testing of project-level agent capabilities. The issue affects both project-specific agents (.claude/agents/) and global agents (~/.claude/agents/). The inconsistency suggests a fundamental issue with sub-agent execution context rather than a configuration problem.
Logs/Screenshots
Testing showed agents providing detailed success messages and even mock directory listings, but filesystem verification consistently shows no files were created. This suggests the Write tool reports success within the agent's execution context but the changes don't persist to the actual filesystem.
Activity
RGCsAGupta commentedon Jul 25, 2025
cc @RGCsAGupta - Original reporter who discovered and systematically tested this agent file writing persistence issue.
deksden commentedon Jul 28, 2025
Some write problems are in-effect inside IDE's terminal, but system terminal is ok
jchavannes commentedon Aug 1, 2025
For me this seems to have affected a single subagent. I created a new agent and it was able to save/edit files. Using iTerm2.
RGCsAGupta commentedon Aug 1, 2025
Thanks @deksden I worked for me by using system terminal.
trytofly94 commentedon Aug 5, 2025
I am on mac using Terminal and none of my agents are actually doing the things they claim to. no file creation, no gh interaction, nothing. Does someone have a workaround for that? Otherwise I would like to reopen the issue...
jakewhelan commentedon Aug 6, 2025
I'm having this issue today too, sub-agents are just burning tokens and not actually doing anything.
and so on
Please re-open this issue.
aoezdTchibo commentedon Aug 7, 2025
The issue persists across both IDE and system terminals. The sub-agent consumes excessive tokens without producing results - files are not being saved upon completion. 😕
RGCsAGupta commentedon Aug 7, 2025
23 remaining items
HengWoo commentedon Jan 5, 2026
GitHub Issue Comment: Plugin-Defined Agents Tool Execution
For issue: #4462
Root Cause Found: Explicit
tools:Field Causes SandboxingAfter systematic testing, I found that plugin-defined agents with an explicit
tools:field run in sandboxed mode where tool operations don't persist to the filesystem.Test Results
tools:fieldpr-review-toolkit:code-reviewerpr-review-toolkit:code-simplifierplugin-dev:plugin-validator["Read", "Grep", "Glob", "Bash"]plugin-dev:skill-reviewer["Read", "Grep", "Glob"]verification-auditorThe Pattern
tools:field → Tools run in sandboxed/simulated mode (claims success, nothing persists)tools:field → Agent inherits all tools and they execute on real filesystemThe Fix
Remove the
tools:field from the agent's YAML frontmatter:Confirmed Working
After removing the
tools:field and restarting Claude Code:Our verification-auditor agent now correctly:
pytestand reports accurate test countsEnvironment
tools:Workaround
If you need to restrict tools, use built-in
general-purposeagent instead:But ideally, just omit the
tools:field entirely.fix(dev-ralph): remove tools field from verification-auditor to fix s…
fix(dev-ralph): improve verification system reliability (#13)
spalladino commentedon Jan 15, 2026
Same with edits here. I asked the main agent what happened and got back:
thevictor13 commentedon Jan 20, 2026
I've just run into this myself. Output files were created, but empty for all 5 sub-agents. That was a large heap of tokens for a pile of nothing.
jonsboris commentedon Jan 23, 2026
Might be a sandbox issue — try disabling it and re-testing. Most likely the sub-agents are writing files inside the sandbox, so you’re seeing stale/isolated outputs. Otherwise it could be that known Claude bug the team hasn’t been able to fix since July.
jonsboris commentedon Feb 8, 2026
He made a mistake twice and didn’t realize he wasn’t writing to the disk. Then he ran it again with subagents and still didn’t write to the disk.
If anyone has similar issues, please write your errors here in this chat! This problem has existed since July, and it hasn’t been fixed yet! Let’s bring this issue up, and maybe the developers will solve it! Subagents are wasting tokens for nothing and cannot write files to the disk.
S23Web3 commentedon Feb 11, 2026
[BUG] Filesystem Write Operations Fail Silently After Session Compaction in Claude Desktop (Windows)
Issue persists
workaround not possible in windows 11
lost tokens and time
gained frustration and weight
Environment
Platform: Windows 11 x64
Claude Interface: Claude Desktop (claude.ai web interface)
Session Type: Extended conversation (6+ hours, ~100K tokens)
Date: 2026-02-11
Trigger Event: Session compaction/context window management
Summary
Filesystem write operations via MCP tools (
create_file,bash_tool) fail silently after extended session duration and context window compaction. Tools return success messages but no files are created on disk. Read operations continue functioning normally throughout the session.Bug Classification
Detailed Description
Expected Behavior
When Claude executes
create_fileorbash_toolwith file write operations:list_directoryshould show created fileread_text_fileshould read created file contentsActual Behavior
After session compaction event:
create_filereturns:"File created successfully: [path]"list_directoryshows: File does not existread_text_filereturns:"ENOENT: no such file or directory"Temporal Pattern
Session Start (T+0h) → Tools likely functional
Mid-Session (T+2-3h) → Context limit reached, compaction triggered
Post-Compaction (T+3-6h) → All write operations fail silently
Session End (T+6h) → Problem persists, no recovery
Reproduction Steps
Test 1: Basic File Creation
Input:
create_file with path and content
Expected Output:
File created successfully message
Verification:
list_directory on same path
Expected Result: File listed in directory
Actual Result: File not present in listing
Test 2: Bash Tool File Creation
Input:
echo "Test content" > file path
Expected Output:
Command executed successfully
Verification:
ls command to find file
Expected Result: File listed
Actual Result:
Error: cannot create file: Directory nonexistent
Test 3: Read Operations (Control)
Input:
list_directory on path
Result: ✅ WORKING - Returns accurate directory listing
Input:
read_text_file on existing file
Result: ✅ WORKING - Returns file contents correctly
Systematic Test Results
Pattern: Read operations functional, write operations broken
Evidence Collection
Attempt 1: File Creation
[create_file called]
Result: "File created successfully"
[list_directory called on same path]
Result: File not in listing
[read_text_file called on created file]
Result: "ENOENT: no such file or directory"
Attempt 2: Verification Loop
Create file → Success message
List directory → File absent
Create same file again → Success message (no "already exists" error)
List directory → File still absent
Observation: Tool claims success repeatedly for same path without conflict errors, confirming writes not reaching filesystem
Attempt 3: Bash Tool
Command: cat > file with content
Error: cannot create file: Directory nonexistent
Observation: Directory exists for read tools, doesn't exist for write tools
Impact Assessment
Session Productivity Loss
Affected Operations
User Experience Impact
Technical Analysis
Hypothesized Root Cause
Based on error patterns and Issue #5505 analysis:
Primary Hypothesis: Session state corruption after context window compaction
Supporting Evidence:
Mechanism:
Session Start → Context accumulation (~100K tokens) → Compaction triggered (transcript creation) → Filesystem write context corrupted/lost → Tools return cached success responses → No actual filesystem operations executed
Alternative Hypotheses
H2: Permission Degradation
H3: Execution Layer Disconnect
H4: Sandboxing After Compaction
Diagnostic Data
Session Metrics
Tool Call Frequency
create_file: 6 calls → 6 "success" returns → 0 files created
bash_tool: 4 calls → 4 errors returned → 0 files created
list_directory: 20+ calls → All accurate
read_text_file: 15+ calls → All accurate
Error Message Analysis
Bash Tool Error Pattern:
/bin/sh: 1: cannot create [path]: Directory nonexistent
Inconsistency:
Create File Tool Pattern:
Comparison with Related Issues
Issue #5505 (Closed as Duplicate)
Similarities:
Differences:
Issue #4462 (Original, Still Open)
Similarities:
Differences:
Current Workarounds
Effective Workarounds
Manual File Creation
Session Restart
Ineffective Workarounds
Retry Same Command ❌
Alternative Tool Selection ❌
Path Modification ❌
Recommendations
For Users (Immediate)
Verify File Creation Externally
Session Length Management
Content Preservation
For Anthropic (Development Team)
Immediate Investigation
Diagnostic Improvements
Error Handling
Testing Requirements
Additional Context
Session Characteristics
Pre-Compaction Phase (Estimated T+0 to T+2h):
Post-Compaction Phase (T+3h to T+6h):
Compaction Event Details
Evidence of Compaction:
Session summary message appeared stating:
"This conversation was successfully compacted to free up space
in the context window. Full uncompacted conversation is stored
in a transcript file accessible via read and bash tools."
Correlation:
Conclusion
This bug represents a critical failure in the filesystem write pathway that occurs reliably after session compaction in long-running conversations. The issue is particularly insidious because:
The bug severely impacts productivity by making file creation non-functional while providing misleading success feedback. Work can only be preserved through manual extraction from conversation history.
Recommendation: High priority fix required for session state management and filesystem tool execution layer.
Appendix: Raw Error Logs
Sample Error 1: Create File Tool
Tool Call: create_file
Parameters: path and content provided
Response: "File created successfully"
Verification (list_directory): File NOT PRESENT
Sample Error 2: Bash Tool
Command: cat > file with content
Error Output: cannot create file: Directory nonexistent
Verification (ls command): Directory not accessible
Verification (list_directory tool): Directory accessible with files shown
INCONSISTENCY: Directory exists for read tools, doesn't exist for write tools
Sample Error 3: Repeated Creation Attempt
Attempt 1: create_file("test.md") → "File created successfully"
Verification: test.md NOT present
Attempt 2 (same file): create_file("test.md") → "File created successfully" (no "already exists" error)
Verification: test.md STILL NOT present
OBSERVATION: No conflict detection, suggests writes not reaching filesystem layer
Jodre11 commentedon Apr 2, 2026
Still reproducing on v2.1.90 with Bedrock. My settings.json has
"defaultMode": "plan"for the interactive session. When dispatching subagents via the Agent tool withmode: "auto"or evenmode: "bypassPermissions", the subagents still inherit plan mode — Bash and Write/Edit tools are denied.The
modeparameter on the Agent tool appears to have no effect;defaultModefrom settings.json always wins. This makes it impossible to use plan mode for the parent session while allowing subagents to execute autonomously.GFrierson commentedon Apr 15, 2026
+1 this still happens for my subagents - writes or modification coming through are inconsistent to the point where I can no longe rely on them and force them to give edits to the parent agent for writing.
Mac os 15.6
Thinking mode true
fastmode false
default model opusplan
v0.11: paleo ghosts — catch subagents that lied about doing work
ianymu commentedon May 26, 2026
The recent paleo commit linked here frames one sharp version of this as
status=completed+ zero tool calls + a side-effect claim.For people still seeing the file-persistence version, is that enough as a receipt, or would you want the check to also compare claimed files against the actual filesystem after the run?
Trying to understand where the proof needs to live before trusting the sub-agent closeout.
migriv24 commentedon Jun 2, 2026
So far the only thing that's worked is switching the model to opus. the default model is NOT working for some reason. I don't know why.