BUG: Task Tool Agents Bypass Plan Mode Write Restrictions

Resolved 💬 4 comments Opened Aug 8, 2025 by coygeek Closed Aug 22, 2025

BUG: Task Tool Agents Bypass Plan Mode Write Restrictions

Summary

Agents invoked via the Task tool can write files even when the main assistant is in Plan Mode (shift+tab), violating the core safety guarantee that Plan Mode prevents all write operations.

Severity

CRITICAL - This is a security/safety issue that undermines the fundamental purpose of Plan Mode

Environment

  • Claude Code Version: 1.0.71
  • Model: claude-opus-4-1-20250805
  • Platform: macOS Darwin 24.6.0
  • Date: 2025-08-08

Steps to Reproduce

  1. Start Claude Code in a directory
  2. Enter Plan Mode using shift+tab
  3. While in Plan Mode, invoke any agent via the Task tool that has write capabilities (e.g., documentation-specialist)
  4. The agent will successfully write files despite Plan Mode being active

Expected Behavior

When Plan Mode is active:

  • ALL write operations should be blocked
  • This should include writes from agents invoked via the Task tool
  • Any attempt to write files should fail with an appropriate error message

Actual Behavior

  • Plan Mode correctly prevents direct Write/Edit tool usage by the main assistant
  • However, agents invoked via Task tool can still write files
  • No error or warning is provided about this bypass

Evidence

Session ID: 12f8749b-798c-4bce-b328-ca957eee43cb
Timestamp: 2025-08-08T17:19:40 - 17:20:54

Sequence of events:

  1. 17:14:28 - Started working in plan mode (never exited until 17:31)
  2. 17:19:40 - Invoked documentation-specialist agent via Task tool:

``json
{
"name": "Task",
"input": {
"subagent_type": "documentation-specialist",
"prompt": "Create a detailed implementation roadmap document..."
}
}
``

  1. 17:20:54 - Agent successfully created file:

``
File created successfully at: /Users/user/Desktop/2025-08-08-find-git/IMPLEMENTATION_ROADMAP.md
``

  1. 17:31:16 - Finally exited Plan Mode with ExitPlanMode tool

Impact

  • Security Risk: Plan Mode is meant to be a safety mechanism to prevent unintended file system modifications
  • User Trust: Users rely on Plan Mode to review changes before execution
  • Data Safety: Unintended writes could modify or overwrite important files

Root Cause Analysis

The Task tool appears to spawn agents in a separate context that doesn't inherit the Plan Mode restrictions from the parent session. These child agents have their own tool permissions that aren't constrained by the parent's Plan Mode state.

Suggested Fix

  1. Immediate: Task tool should check parent session's Plan Mode state before allowing child agents to perform write operations
  2. Comprehensive: All tool invocations (including nested/child agent calls) should respect the Plan Mode state of the root session
  3. Safety Check: Add explicit Plan Mode state propagation to all agent invocations

Workaround

Until fixed, users should:

  • Avoid using Task tool while in Plan Mode
  • Be aware that Plan Mode does NOT currently prevent writes from Task-invoked agents
  • Manually verify no unintended files were created after using agents in Plan Mode

Additional Context

The file IMPLEMENTATION_ROADMAP.md (13,491 bytes) was created at 10:20 AM while the assistant was in Plan Mode. This file creation was not requested by the user and violated the Plan Mode contract.

Reproducibility

100% - This behavior is consistent and reproducible

Priority

This should be treated as a P0/P1 bug as it compromises the fundamental safety guarantee of Plan Mode.

---
Bug report generated after discovering unexpected file creation in Plan Mode session

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗