claude-code - 💡(How to fix) Fix Agent tool: parallel agents with destructive operations cause data loss — needs sequencing guardrails [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47005Fetched 2026-04-13 05:44:01
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

The Agent tool allows spawning parallel agents with no dependency awareness. When Agent A (transfer) and Agent B (cleanup/delete) operate on the same source files, there is no mechanism to enforce ordering. The model should have sequenced them, but the tool doesn't warn or prevent this pattern.

  1. When multiple agents are spawned in the same message and one performs destructive operations (rm, delete, move) on paths that another agent reads from, the system should warn the model or enforce sequential execution.

Root Cause

Root cause: The Agent tool allows spawning parallel agents with no dependency awareness. When Agent A (transfer) and Agent B (cleanup/delete) operate on the same source files, there is no mechanism to enforce ordering. The model should have sequenced them, but the tool doesn't warn or prevent this pattern.

RAW_BUFFERClick to expand / collapse

Bug / Feature Request

What happened: User asked to transfer files from directory A to directory B, then clean up directory A. Two agents were spawned in parallel — one to transfer, one to clean up. The cleanup agent finished first and deleted the source files before the transfer agent could copy them. Result: 22 files (~7,400 lines of research content representing hours of user work and token spend) permanently lost. No git repo, no trash, no backup. Unrecoverable.

Root cause: The Agent tool allows spawning parallel agents with no dependency awareness. When Agent A (transfer) and Agent B (cleanup/delete) operate on the same source files, there is no mechanism to enforce ordering. The model should have sequenced them, but the tool doesn't warn or prevent this pattern.

What should happen:

  1. When multiple agents are spawned in the same message and one performs destructive operations (rm, delete, move) on paths that another agent reads from, the system should warn the model or enforce sequential execution.
  2. At minimum: the Agent tool documentation/system prompt should explicitly call out that destructive operations must never run in parallel with read operations on the same paths.
  3. Ideally: a dependency parameter (e.g., depends_on: [agent_id]) so agents can be sequenced when needed while still allowing true parallelism for independent work.

User impact: Permanent data loss. Hours of paid research work destroyed. Trust broken. The user's own instructions said "launch multiple agents" — they trusted the system to handle parallelism safely. The model should have known better than to parallelize transfer + delete on the same files, but there are no guardrails when it doesn't.

Environment: Claude Code on Windows 11, Claude Opus 4.6, Agent tool with general-purpose subagent_type.

Reproduction: Spawn two parallel agents where Agent A reads files from path X and Agent B deletes files from path X. Race condition is near-guaranteed.

extent analysis

TL;DR

To prevent data loss, ensure that agents performing destructive operations on a path do not run in parallel with agents reading from the same path by implementing a dependency mechanism or sequential execution.

Guidance

  • Identify and document all instances where agents may be spawned in parallel with potential read-write conflicts, and manually sequence them if necessary.
  • Modify the Agent tool to either warn about or prevent parallel execution of agents with destructive operations on paths that other agents are reading from.
  • Consider adding a depends_on parameter to allow for explicit sequencing of dependent agents while preserving parallelism for independent tasks.
  • Review and update the Agent tool documentation to explicitly caution against running destructive operations in parallel with read operations on the same paths.

Example

A potential code change could involve introducing a depends_on parameter, for example:

agent_a = Agent("read_files", path="X")
agent_b = Agent("delete_files", path="X", depends_on=[agent_a.id])

This would ensure that agent_b only starts after agent_a has completed.

Notes

The solution requires careful analysis of existing agent workflows to identify potential conflicts and may need significant updates to the Agent tool and its documentation. The introduction of a dependency mechanism can add complexity but is necessary to prevent data loss.

Recommendation

Apply a workaround by manually sequencing agents with potential read-write conflicts until a permanent fix with dependency awareness is implemented, as this will immediately prevent further data loss.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Agent tool: parallel agents with destructive operations cause data loss — needs sequencing guardrails [1 comments, 2 participants]