Skip to content

fix(plan): harden plan mode — deny escape, show preview, guard empty#21866

Open
BYK wants to merge 3 commits intoanomalyco:devfrom
BYK:fix/plan-mode-hardening
Open

fix(plan): harden plan mode — deny escape, show preview, guard empty#21866
BYK wants to merge 3 commits intoanomalyco:devfrom
BYK:fix/plan-mode-hardening

Conversation

@BYK
Copy link
Copy Markdown
Contributor

@BYK BYK commented Apr 10, 2026

Issue for this PR

Closes #18515

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Three plan-mode hardening fixes:

1. Deny plan_exit/plan_enter in subagent sessions (task.ts)
Subagents spawned by the task tool can call plan_exit or plan_enter, escaping the current plan mode context. Adds deny rules to both the session permission array and the tools map, alongside the existing todowrite/task deny rules.

2. Show plan content as markdown preview in exit prompt (plan.ts)
When plan_exit fires, the question dock now shows the full plan file rendered as markdown below the prompt. This lets the user review the plan before approving the switch to build mode.

3. Guard against empty plan files (plan.ts)
If the plan file is empty or missing, plan_exit returns an error telling the agent to write the plan first, instead of showing an empty approval prompt.

How did you verify your code works?

  • Subagents no longer have plan_exit/plan_enter in their tool list
  • Plan content renders as markdown in the question dock
  • Empty plan files show an error message instead of an empty prompt

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

BYK added 2 commits April 10, 2026 11:28
…plan

Read the plan file content and append it as a markdown preview in the
plan_exit question. Also guard against empty plan files — return an
error telling the agent to write the plan first.
The question text in the dock was rendered as plain text, making plan
content from plan_exit unreadable. Use the Markdown component to render
it properly.
@BYK BYK requested a review from adamdotdevin as a code owner April 10, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planning mode: subagents can trigger plan_exit, plan not shown before build switch, question text renders as plain text

1 participant