[BUG] ExitPlanMode terminates the current turn — prevents post-plan execution in SDK sessions
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
When ExitPlanMode is called, it terminates the current turn immediately. No further tool calls execute after ExitPlanMode within the same turn — the ResultMessage is emitted and the turn ends.
This means any workflow that enters plan mode, gets user approval, exits plan mode, and then executes actions (Agent dispatch, Bash, Write, etc.) cannot complete in a single turn. A follow-up turn/prompt is required after ExitPlanMode to continue execution.
Reproduction
Prompt Claude with explicit step-by-step instructions:
1. Call EnterPlanMode
2. Read a file
3. Ask user for approval via AskUserQuestion
4. Call ExitPlanMode
5. Run: echo HELLO via Bash
Observed tool sequence:
ToolSearch → EnterPlanMode → Read → AskUserQuestion → ToolSearch → ExitPlanMode
Step 5 (Bash) never executes. The turn completes immediately after ExitPlanMode.
Expected: All 5 steps complete in a single turn.
Impact
This breaks plan-then-execute workflows in SDK-based automation. For example, a design orchestrator that:
- Enters plan mode to analyze requirements
- Asks the user to approve the design scope
- Exits plan mode
- Dispatches 9 sub-agents to write design documents
...can never reach step 4 because ExitPlanMode at step 3 terminates the turn.
Workaround
Send a follow-up query() / prompt after ExitPlanMode to continue execution in a new turn. This works but requires the caller to detect the plan mode exit and re-prompt.
Environment
- Claude Code CLI: 2.1.86
- Claude Agent SDK: 0.1.52 (Python)
permission_mode="bypassPermissions"- Linux (Docker)
Related
Cross-filed from anthropics/claude-agent-sdk-python#774
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗