#18516 · @BYK · opened Mar 21, 2026 at 11:50 AM UTC · last updated Mar 21, 2026 at 7:35 PM UTC
fix(plan): prevent subagent plan escape, show plan in exit prompt, render as markdown
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR fixes three critical issues in the experimental planning mode, preventing subagents from prematurely exiting the plan, displaying the full plan content before building, and correctly rendering markdown in the question dock. It improves the stability and user experience of this feature.
Description
Issue for this PR
Closes #18515
Type of change
- [x] Bug fix
- [ ] New feature
- [ ] Refactor / code improvement
- [ ] Documentation
What does this PR do?
Fixes three issues with the experimental planning mode (OPENCODE_EXPERIMENTAL_PLAN_MODE):
1. Subagents can escape plan mode — When the plan agent spawns explore/general subagents via the task tool, those child sessions had access to plan_exit. If a subagent called it and the user accidentally confirmed, the session would switch to build mode prematurely. Fix: deny plan_exit and plan_enter permissions in subagent session creation (task.ts), alongside the existing todowrite/todoread denials.
2. Plan not shown before build switch — plan_exit asked "Would you like to switch?" without showing what the plan actually says. The user had to go read the plan file separately. Fix: read the plan file content in PlanExitTool and append it to the question text below a horizontal rule, so users see the full plan inline before deciding.
3. Question text renders as plain text — The question dock rendered question.question as raw text insertion, not markdown. Even with the plan content included, headers/lists/code blocks would display unformatted. Fix: use the Markdown component in both the live question dock (session-question-dock.tsx) and historical message display (message-part.tsx). Added overflow-y: auto; max-height: 40vh to the question-text CSS so long plans scroll within the dock.
How did you verify your code works?
- Reviewed the permission deny logic matches the existing pattern for
todowrite/todoread - Verified
Markdowncomponent is already used throughout the UI (message parts, context tabs) and the import path is correct - The CSS change is additive and scoped to
[data-slot="question-text"]within the question dock
Screenshots / recordings
N/A — planning mode is experimental and behind a flag. The markdown rendering change applies to all question docks.
Checklist
- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Linked Issues
#18515 Planning mode: subagents can trigger plan_exit, plan not shown before build switch, question text renders as plain text
View issueComments
No comments.
Changed Files
AGENTS.md
+67−2packages/app/src/pages/session/composer/session-question-dock.tsx
+4−1packages/opencode/src/tool/plan.ts
+7−2packages/opencode/src/tool/task.ts
+10−0packages/ui/src/components/message-part.css
+2−0packages/ui/src/components/message-part.tsx
+3−1