Skip to content

Plan mode: "Implement this plan" can stay in plan mode and stall turn startup #462

@amanthanvi

Description

@amanthanvi

Problem

When a user clicks Implement this plan from the plan follow-up card, the next turn can fail in two related ways:

  1. Functional mode-switch failure: the next turn still runs with plan-mode behavior (or appears to stall after the initial goal block) instead of switching to implementation mode.
  2. UI/state-sync failure: the collaboration mode UI and thread-scoped codex params can remain on plan, causing future turns to keep inheriting plan mode unexpectedly.

Why this is happening

Current plan-accept flow depends on collaboration modes being loaded and resolvable at click time. In race/fallback scenarios (e.g. mode list not yet loaded, stale selection, or only plan available in-memory), the follow-up message can be sent without a safe non-plan override and without persistently updating thread-scoped mode state.

Reproduction

  1. Start a thread in plan mode and wait for a plan tool output.
  2. Click Implement this plan quickly after reconnect/thread switch (or when mode list is still refreshing).
  3. Observe one or more outcomes:
    • turn starts with plan-like behavior instead of implementation behavior,
    • agent emits initial goal block then appears stuck/stopped,
    • collaboration mode UI still shows/sticks to plan for that thread.

Expected behavior

  • Clicking Implement this plan should deterministically start the next turn in a non-plan mode.
  • UI selection and persisted thread codex params should switch out of plan in lockstep.
  • If no safe non-plan mode is currently resolvable, the follow-up turn should still send an explicit neutral mode override rather than inheriting stale plan state.

Proposed fix (frontend-focused)

  • Harden mode resolution for plan-accept:
    • prefer default, then code, then first non-plan mode,
    • never fallback to plan for implement action.
  • Always send explicit per-turn collaboration-mode option on plan-accept:
    • resolved non-plan payload when available,
    • explicit collaborationMode: null when not.
  • Persist thread-scoped collaboration mode id during plan follow-up actions so UI + behavior stay aligned.

Acceptance criteria

  • Implement this plan never sends a plan-mode payload.
  • In plan-only/empty-mode race states, accept sends explicit neutral override (collaborationMode: null).
  • Thread codex params persist collaboration mode transition on accept (non-plan or null).
  • Visual collaboration mode state remains consistent after accept, including thread switch/reselect.
  • Regression tests cover default/code/non-plan fallback and plan-only/empty-mode race scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions