Skip to content

plan_exit in a child session asks and switches the child, not the root session #637

Closed

Description

@agenteinstinct1-max

Found while reviewing #545 at 64007a4 / base 04c93b3; the behavior is in dev-vibecoded (packages/opencode/src/tool/plan.ts) and not introduced by #545, which only changes which plan path is named.

PlanExitTool.execute resolves the plan file from the session, but Question.ask and the synthetic "work" user message both use ctx.sessionID. When plan_exit runs in a delegated child session, the approval question and the synthetic switch-to-work message land on the child, so the child switches to Work, not the root session that owns the plan. Existing test coverage reads the child's messages (test/session/reminders.test.ts, plan_exit tests).

Currently latent: plan_exit is not in the Work/Think inspection set (packages/core/src/work-flow.ts), so it is stripped in programming/uncertain sessions (registry.ts:312-322), and subagent permissions (subagent-permissions) do not deny it, so it is reachable only where tool admission does not strip it.

Expected: decide whether plan_exit may run in a child at all; if it may, ask and post the switch on the root session. If not, deny it in subagent permissions.

Activity

  1. agenteinstinct1-max commented on Oct 26, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Fixed by #642, squash c20f0bf. Decision: plan_exit is not allowed in a child session. It now refuses with a clear error, asks no question and posts no message, so neither the child nor the root is switched. Root behaviour is unchanged. New test/tool/plan.test.ts covers child refusal, root pass and the adversarial cases; the child test fails with the src change reverted. Not covered: the tool is still advertised to child sessions (the guard errors safely at call time), and the subagent permission list is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions