[BUG] Sub-agents claim successful file creation but files don't persist to filesystem
[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:
``bash``
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:
``/path/to/agent-file-test.md
I have successfully created the test file ``
- Verify file doesn't exist:
``bash``
ls -la | grep agent-file-test
find . -name "*agent*test*" 2>/dev/null
# Both return no results
- Control test - Direct Write tool works:
``bash``
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
- #4182 - Sub-Agent Task Tool limitations
- #3978 - Task tool transparency issues
- #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.
39 Comments
cc @rgcsagupta - Original reporter who discovered and systematically tested this agent file writing persistence issue.
Some write problems are in-effect inside IDE's terminal, but system terminal is ok
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.
Thanks @deksden I worked for me by using system terminal.
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...
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.
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. 😕
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I've been having this issue for 2 weeks now. Creating new subagents or re-installing Claude Code sometimes fixes the issue temporarily, but it keeps coming back again.
EDIT:
Possible root cause - I have instructions in
CLAUDE.mdto delegate to subagents whenever possible. IfCLAUDE.mdis inherited by subagents then they will see these instructions and try to delegate as well.I have updated
CLAUDE.mdinstructions to differentiate between top-level and subagents, telling subagents to actually execute and not delegate. This seems to have cleared up the issue for me for now.EDIT 2:
Nevermind, still having the same issue. I think subagents don't "know" they are subagents and still follow top-level instructions to try to delegate. It would be great to have an
.mdfile that is only read by the top level Claude Code and not subagents.if the sub agents have:
should be:
It might be the cause, ensure the tools are comma separated (or use the claude code cli
/agentcommand to edit the agent tools and update the agent tools)I have just experienced this today. Very frustrating to burn through tokens, hit your session limit, then review the git commits only to find that all they do is modify
tasks.mdto claim that a bunch of sub-tasks have been accomplished when in fact all the code changes were discarded along the way.my claude code conclusion
"
DISCOVERY: The Fundamental Truth About Claude Code Sub-Agents
Through systematic investigation using available MCP resources, I've uncovered the critical information that explains exactly why the multi agent (CCAPM) system cannot work as designed:
Core Issue: Sub-Agents Operate in Isolated Simulation Environments
The official GitHub issues definitively confirm what we discovered through testing:
Architecture Reality vs. Design
CCAPM's Fundamental Assumption (WRONG): All agents can coordinate through shared MongoDB access.
Claude Code Reality (CONFIRMED):
I'm getting this on Win11 1.0.90 without agents. Permissions are correctly configured, Write and Edit work in an isolated sandbox environment
Same issue for me #7382
I have not had success with agents writing files, even though they report success.
A generic Hyprland setup.
Didn't have success on mac either.
I encountered this issue on Ubuntu (here). I tried 3 different terminals, both within and outside of an IDE. It made no difference.
I’ve been hitting this problem probably 30% of the time.. very annoying
same issue. no matter how explicitly I tell the subagents to write their output to a file, they won't and many times they will say they did too.
The only working way for me was to allow tools for my agents via Claude console:
/agents-> choose your agent ->Edit agent->Edit tools-> allow necessary tools.<img width="356" height="236" alt="Image" src="https://github.com/user-attachments/assets/6f8ed79a-e94e-45ef-bed7-44d50de6973e" />
Editing of agents's .md file Tools section doesn't work, editing Settings has no effect.
After success I found that in the official documentation this way of editing agents is preferable .
_Claude code version 1.0.126 + Jetbrains Claude Code Plugin 0.1.11-beta + Mac OS_
I just wasted so many hours.
How has this issue been open for so long without being addressed or responded to?
I was going crazy trying to understand why my subagents were causing so many issues, and it's because all of thier work is imaginary and they can't even TELL.
I don't even know if this can be fixed by an environment change or uninstall, or anything. I've tried three environments now with the same failures.
EDIT: Tested on my other computer, and my subagents work in that environment.
I couldn't tell you why. Guess I'll try to uninstall.
I no longer have this issue after asking Claude to review each agent and insure they are compatible with the latest version.
I worked with Claude Code, and we eventually were able to solve this. I think the key insight that Claude had was to force the use of the Write tool, which was not happening for those sub-agents. I asked Claude to write up a quick summary of how we solved this problem on my project, maybe some of this can be helpful...
Solution: Forcing Sub-Agents to Write Output to Files
We solved this by implementing a three-part approach:
explicit instructions to use the Write tool for persisting outputs. The agents
needed clear directives stating they must write to disk, not just return
content.
explicitly instruct them in the prompt to:
checking that files actually exist on disk rather than trusting agent responses
alone.
Key Insight: The problem was that agents defaulted to returning content as
tokens in their response rather than persisting to disk. Making file writing an
explicit, verified requirement in both the agent definition AND the Task
invocation prompt solved the issue.
Example working pattern:
Task prompt: "Research XYZ and write your findings to outputs/research.md using
the Write tool"
Then verify: Check that outputs/research.md exists with expected content
Posting my findings here and perhaps it will help someone. I had claude do some refactoring on my agent files and one of the things it ended up doing was formatting my tools list in the YAML frontmatter as a multi-line array. Apparently, multi-line tool arrays don't work for the frontmatter and since I was spawning the sub-agents from the task tool it was inheriting the read-only permissions and hallucinating the writes (since I had gone as far as explicitly telling it to use the write tool).
Changing the frontmatter to a single-line, comma delimited list of tools instead of a mult-line array fixed my issue and now everything is working smoothly again.
P.S. - It would be nice if multi-line arrays were supported in the YAML frontmatter.
@claude is basically worthless now because of this error. In the past 2 weeks, 80% of the work done for us by custom sub-agents failed to persist to disk.
We've had to switch all of our agentic efforts to Kiro and Gemini because Claude has cost us collectively hundreds of hours since November 1st .
Guardrails are not helping. We can ask Claude 100 times to verify that the agent persisted its work to disk, and it will lie 100 times.
@anthropics you have more money than many countries, do better.
Still open - ran into this last week. Claude tried to convince me it's intentional design that agents can't persist to disk... nice try.
I really like the agentic approach, but if agents can't persist their results they are more or less useless.
In my case it seems that it was an issue that the tools allowed for the agents in the frontmatter were written in lowercase. After changing this to uppercase the agents worked again as expected.
BUT some of the tools seemed to work before although they were written in lowercase. So it feels inconsistent, which is a bad thing for something related to code.
Can confirm that the problem persists, but it's interesting that the behavior is inconsistent.
For example I've used plugin from the official source
https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/agents/agent-creator.md
Via calling this plugin to create an agent in the plugin directory - it succeeded, plugin files for the agent
project-scaffolding-agentwere created.When I tried to use this newly created plugin's agent:
On second attempt I even added instructions to force usage of the tools (like you see above), it didn't helped at all.
Either I get error that the response max token limit is reached, or agent replies that everything is created, but the folder is empty.
Not sure what is the problem here.
I had claude code spawn subagents to handle a divide & conquer task, each subagent with a folder to write their results to. Claude reported that task was successfully finished, even generated a summary doc to indicate completion with the line count details on each subagent's findings, and I am now discovering the folders are in fact empty.
<img width="1105" height="457" alt="Image" src="https://github.com/user-attachments/assets/c93110b7-a7d1-4323-bd98-698c1ffb8f73" />
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
| Agent |
tools:field | Bash/Write persists? ||-------|----------------|---------------------|
|
pr-review-toolkit:code-reviewer| Not specified | ✅ Yes ||
pr-review-toolkit:code-simplifier| Not specified | ✅ Yes ||
plugin-dev:plugin-validator|["Read", "Grep", "Glob", "Bash"]| ❌ No ||
plugin-dev:skill-reviewer|["Read", "Grep", "Glob"]| ❌ No || Custom
verification-auditor| YAML list with Bash | ❌ No |The 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:| Check | Before | After |
|-------|--------|-------|
| Bash execution | Sandboxed | ✅ Real |
| File writes | Not persisted | ✅ Persisted |
| Tool accuracy | Fabricated outputs | ✅ Accurate |
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.Same with edits here. I asked the main agent what happened and got back:
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.
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.
<img width="1092" height="95" alt="Image" src="https://github.com/user-attachments/assets/9d84e281-e67b-4051-9b17-74ab41c964b8" />
lol)
<img width="1230" height="367" alt="Image" src="https://github.com/user-attachments/assets/a28fd4d2-dc16-44fe-a83b-8ae5cf625158" />
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.
[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
| Tool | Operation | Return Status | Filesystem Result | Error Message |
|------|-----------|---------------|-------------------|---------------|
| create_file | Write new file | ✅ Success | ❌ Not created | None |
| bash_tool | cat > file | ❌ Error | ❌ Not created | "Directory nonexistent" |
| bash_tool | echo > file | ❌ Error | ❌ Not created | "Directory nonexistent" |
| list_directory | Read dir | ✅ Success | ✅ Accurate | None |
| read_text_file | Read file | ✅ Success | ✅ Accurate | None |
| search_files | Search | ✅ Success | ✅ Accurate | None |
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
Ineffective Workarounds
---
Recommendations
For Users (Immediate)
For Anthropic (Development Team)
---
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
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.+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
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.
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.