[BUG] Self-hosted runner: session waiting on ExitPlanMode approval is idle-released, and the approval prompt is orphaned on resume
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?
On a self-hosted environment, a session that has called ExitPlanMode and is waiting for the user to approve the plan gets released by --release-idle-session-min. When the user returns and the session resumes on a fresh runner, the pending approval is gone. The ExitPlanMode call comes back with "You are not in plan mode", so the user never gets to approve the plan.
This happened twice in one session, after idle windows of about 5 h and about 1 h. On the second resume the debug log showed:
Plan file missing during resume: .../plans/<name>.md. Attempting recovery.
Plan recovered from file snapshot, 21236 chars
The reference for --release-idle-session-min says a session "still mid-turn, including one holding ... an approval requested from inside a running tool call, doesn't count as idle". A pending ExitPlanMode approval is a tool call waiting on the user, so by that description the session should not have been released.
What Should Happen?
Either:
- a pending
ExitPlanModeapproval keeps the session from being released, as other in-tool approvals do; or - if it is released, the approval prompt is restored on resume, so the user can still approve or reject the plan.
Error Messages/Logs
ExitPlanMode result on resume: You are not in plan mode
Steps to Reproduce
- Run
claude self-hosted-runnerwith--release-idle-session-min 10. - In a session, enter plan mode and let Claude call
ExitPlanMode. - Do not respond to the approval prompt for more than 10 minutes.
- The runner releases the session.
- Send a message to resume it on a fresh runner.
- The approval prompt is gone, and the
ExitPlanModecall reports "You are not in plan mode".
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.294
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Related: #100474 (resumed session re-enters plan mode despite an explicit --permission-mode).