Incorrect ExitPlanMode Trigger in Custom Planning Workflows

Resolved 💬 3 comments Opened Aug 22, 2025 by wdelhagen Closed Aug 25, 2025

Bug Description

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.85 (Claude Code)
  • Operating System: macOS 14.6.1
  • Terminal: iTerm2

Bug Description

The ExitPlanMode tool was incorrectly triggered at the end of creating an implementation plan. This tool should only be used when in system "plan mode" (initiated by the user using the shift+tab cycling operation to select "plan mode" while in the 'opusplan' model), but it was called even though the system was in 'opus' mode and "plan mode" was not active. The agent was asked to create a plan document, which it did successfully, but then inappropriately attempted to exit a plan mode that was never entered by triggering the ExitPlanMode tool.

Steps to Reproduce

  1. User runs /remind command to refresh memory of core principles
  2. User provides a design document reference: @plan/<project-title>-design.txt
  3. User invokes CUSTOM slash command /plan @plan/<project-title>-design.txt (NOT system plan mode)
  4. Agent uses progressive interviewing (/progressive) to gather requirements
  5. Agent creates the implementation plan document successfully at plan/<project-title>-plan.txt
  6. Agent inappropriately calls ExitPlanMode tool despite never being in system plan mode
  7. System responds with "User has approved your plan. You can now start coding."
  8. This corrupts the context window and interrupts workflow

Expected Behavior

The ExitPlanMode tool should only be available and callable when:

  1. The user has explicitly selected the 'opusplan' model as the active model
  2. The user has explicitly entered SYSTEM plan mode via shift+tab cycling
  3. The system is actively in plan mode (NOT when using custom /plan slash commands)

When creating a plan document via custom slash commands or regular document creation, the agent should:

  1. Create the plan document
  2. Inform the user it's complete
  3. NEVER call ExitPlanMode since system plan mode was never entered

Actual Behavior

The agent called ExitPlanMode after creating a plan document, even though:

  1. The system was in regular 'opus' mode, NOT 'opusplan' mode
  2. System plan mode was never activated via shift+tab
  3. The user was using a CUSTOM /plan slash command, which is completely separate from system plan mode
  4. The task was to create a plan document via custom workflow, not system plan mode

The system accepted the ExitPlanMode call and responded with "User has approved your plan. You can now start coding." This:

  • Corrupted the context window with inappropriate system messages
  • Interrupted the established custom workflow
  • Created confusion about whether the user had actually approved something
  • Injected system plan mode artifacts into a non-plan-mode conversation

Additional Context

Critical distinction that causes this bug:

  1. SYSTEM plan mode: Activated via shift+tab to select 'opusplan' model - this is when ExitPlanMode should be used
  2. CUSTOM /plan slash command: User-created workflow command that has NOTHING to do with system plan mode

The agent is confusing these two completely separate systems. When it sees planning-related content or the word "plan", it incorrectly assumes system plan mode is active and tries to use ExitPlanMode.

Impact on users:

  • This bug has occurred multiple times
  • Each occurrence corrupts the context window with system messages
  • Interrupts carefully designed custom workflows
  • Creates confusion about approval states
  • Forces users to add explicit warnings to their CLAUDE.md files banning ExitPlanMode

Key evidence of the confusion:

  • User invoked custom /plan slash command (part of their 5-stage workflow)
  • Agent created plan/<project-title>-plan.txt as requested
  • Agent then called ExitPlanMode (system tool for 'opusplan' mode)
  • System injected "User has approved your plan" message into non-plan-mode context

Root cause:
The agent cannot distinguish between:

  • Custom user workflows that happen to involve planning
  • System plan mode that requires ExitPlanMode

Recommended fixes:

  1. ExitPlanMode should ONLY be available when system is actually in 'opusplan' mode
  2. Better documentation/training for agents about the distinction between system modes and custom commands
  3. Consider renaming ExitPlanMode to ExitSystemPlanMode for clarity
  4. Add safeguards to prevent ExitPlanMode from being called outside of actual plan mode context

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 1.0.88
  • Feedback ID: c2cc2053-41ff-4b1c-86d9-5f3e0a4335c5

Errors

[{"error":"Error: Request was aborted.\n    at XP.makeRequest (file:///Users/willd/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:943:3840)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-08-22T07:43:54.349Z"}]

View original on GitHub ↗

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