Incorrect ExitPlanMode Trigger in Custom Planning Workflows
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
- User runs
/remindcommand to refresh memory of core principles - User provides a design document reference:
@plan/<project-title>-design.txt - User invokes CUSTOM slash command
/plan @plan/<project-title>-design.txt(NOT system plan mode) - Agent uses progressive interviewing (
/progressive) to gather requirements - Agent creates the implementation plan document successfully at
plan/<project-title>-plan.txt - Agent inappropriately calls ExitPlanMode tool despite never being in system plan mode
- System responds with "User has approved your plan. You can now start coding."
- This corrupts the context window and interrupts workflow
Expected Behavior
The ExitPlanMode tool should only be available and callable when:
- The user has explicitly selected the 'opusplan' model as the active model
- The user has explicitly entered SYSTEM plan mode via shift+tab cycling
- The system is actively in plan mode (NOT when using custom
/planslash commands)
When creating a plan document via custom slash commands or regular document creation, the agent should:
- Create the plan document
- Inform the user it's complete
- NEVER call ExitPlanMode since system plan mode was never entered
Actual Behavior
The agent called ExitPlanMode after creating a plan document, even though:
- The system was in regular 'opus' mode, NOT 'opusplan' mode
- System plan mode was never activated via shift+tab
- The user was using a CUSTOM
/planslash command, which is completely separate from system plan mode - 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:
- SYSTEM plan mode: Activated via shift+tab to select 'opusplan' model - this is when ExitPlanMode should be used
- CUSTOM
/planslash 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
/planslash command (part of their 5-stage workflow) - Agent created
plan/<project-title>-plan.txtas 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:
- ExitPlanMode should ONLY be available when system is actually in 'opusplan' mode
- Better documentation/training for agents about the distinction between system modes and custom commands
- Consider renaming ExitPlanMode to ExitSystemPlanMode for clarity
- 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"}]This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗