openclaw - ✅(Solved) Fix [GPT 5.4 v3 Phase 3.C] Plan-mode entry points + approval UX (builds on #61845) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#67520Fetched 2026-04-17 08:30:22
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
cross-referenced ×5referenced ×1

PR #61845 already builds the plan-mode runtime core:

  • SessionRuntimeMode = "plan" | "normal" | "auto"
  • enter_plan_mode / exit_plan_mode agent tools
  • plan-mode-hook.ts mutation gate (blocks 11+ tool categories)
  • todo_write / task_create / task_update plan-mode tools
  • Session-metadata persistence of plan state

This issue covers the layer above #61845: user-facing entry points and the approval UX that makes plan mode trustworthy. Without this, plan mode is two phases with no human review gate.

Root Cause

PR #61845 already builds the plan-mode runtime core:

  • SessionRuntimeMode = "plan" | "normal" | "auto"
  • enter_plan_mode / exit_plan_mode agent tools
  • plan-mode-hook.ts mutation gate (blocks 11+ tool categories)
  • todo_write / task_create / task_update plan-mode tools
  • Session-metadata persistence of plan state

This issue covers the layer above #61845: user-facing entry points and the approval UX that makes plan mode trustworthy. Without this, plan mode is two phases with no human review gate.

Fix Action

Fixed

PR fix notes

PR #67538: feat(agents): plan mode runtime + escalating retry + auto-continue [Phase 3.C]

Description (problem / solution / changelog)

TL;DR

Three complementary features to fix GPT-5.4's planning-only behavior: (1) opt-in plan mode that gates mutating tools until user approval, (2) escalating retry instructions with 3 urgency levels, and (3) opt-in auto-continue that keeps the agent working without human intervention. Together these close the gap between GPT-5.4's cautious defaults and agentic execution.

Tracking

  • Umbrella: #66345
  • Issue: #67520

What this PR does

Plan mode runtime (opt-in)

Two-phase execution: plan (mutation gate ON, read-only tools allowed) → execute (full tool access after approval).

  • Mutation gate: blocks 11 tools (write, edit, exec, apply_patch, message, subagents, etc.), allows read/search/plan
  • Exec whitelist: read-only commands (ls, cat, grep, git log, git diff) pass through even during planning
  • Approval state machine: none → pending → approved | edited | rejected | timed_out
  • Rejection UX: captures feedback text + increments cycle counter for plan revision

Escalating retry (automatic, GPT-5 only)

When planning-only turn detected (text with zero tool calls), up to 3 retries with escalating urgency:

RetryInstruction
1"Act now: take the first concrete tool action"
2"CRITICAL: You MUST call a tool in this turn"
3"FINAL WARNING: Call a tool NOW or this task will be cancelled"

Retry limit raised from 2 → 3 for strict-agentic contract.

Auto-continue (opt-in config)

After retries exhausted, instead of blocking for user input, injects ACK fast-path automatically:

{
  "agents": {
    "defaults": {
      "embeddedPi": {
        "autoContinue": {
          "enabled": true,     // default: false
          "maxCycles": 3,      // each cycle ≈ 4 API calls
          "stopOnMutation": true
        }
      }
    }
  }
}

Flow diagrams

Escalating retry + auto-continue

Model responds (text only, 0 tool calls)
    ├── retry 1: "Act now"
    ├── retry 2: "CRITICAL"
    ├── retry 3: "FINAL WARNING"
    └── retries exhausted
    ┌────┴──────────────┐
    ▼                   ▼
auto-continue       block for user
enabled?             (default)
inject ACK, reset retries, cycle++
    ├── cycle < maxCycles → retry again
    └── cycle = maxCycles → block for user

Plan mode

User message → Plan phase (read-only tools) → Plan produced
    → Approval gate (pending) → User approves/rejects
    → approved: Execute phase (full tools)
    → rejected: Feedback + retry plan phase

API call math

ConfigFormulaWorst case
Default (no auto-continue)1 + 3 retries4 calls
Auto-continue, maxCycles=31 + 3 × (3 retries + 1 ACK)13 calls
Auto-continue, maxCycles=51 + 5 × (3 retries + 1 ACK)21 calls

Files changed

FileChange
src/agents/plan-mode/*.ts (6 files)New — mutation gate, approval state machine, types
qa/scenarios/gpt54-*.md (5 files)New — QA parity scenarios
src/agents/pi-embedded-runner/run.tsAuto-continue wiring, ACK injection, plan event emission
src/agents/pi-embedded-runner/run/incomplete-turn.tsEscalating retry, limit 2→3
src/agents/pi-embedded-runner/run.incomplete-turn.test.tsUpdated + new tests
src/agents/agent-scope.tsresolveAgentAutoContinue() config resolver
src/config/types.agent-defaults.tsautoContinue type
src/config/zod-schema.agent-defaults.tsautoContinue Zod schema

Tests

  • 30 mutation gate tests (tool blocking, exec whitelist, word-boundary matching)
  • 7 approval state machine tests (all transitions, feedback, cycle counting)
  • Escalating retry tests (correct instruction per index, boundary conditions)
  • Auto-continue integration test (maxCycles budget, ACK injection)
  • Total: 50 tests in this PR's test files

Rollback

FeatureDisableEffect
Plan modeDon't activate PlanMode runtimeMutation gate never instantiated
Escalating retryRevert incomplete-turn.ts limit 3→2Single-message retry
Auto-continueautoContinue.enabled: false (default)Blocks for user input

All features are additive. No existing behavior changes unless opted in.

Dependencies

  • #67512 for execution discipline (conceptual, no file overlap)

What follows

  • Dashboard Continue button
  • Channel-native approval buttons (Slack/Discord)
  • /plan slash command

Changed files

  • qa/scenarios/gpt54-act-dont-ask.md (added, +59/-0)
  • qa/scenarios/gpt54-cancelled-status.md (added, +57/-0)
  • qa/scenarios/gpt54-injection-scan.md (added, +58/-0)
  • qa/scenarios/gpt54-mandatory-tool-use.md (added, +57/-0)
  • qa/scenarios/gpt54-plan-mode-default-off.md (added, +61/-0)
  • src/agents/agent-scope.test.ts (modified, +68/-0)
  • src/agents/agent-scope.ts (modified, +33/-0)
  • src/agents/pi-embedded-runner/run.incomplete-turn.test.ts (modified, +101/-5)
  • src/agents/pi-embedded-runner/run.ts (modified, +75/-8)
  • src/agents/pi-embedded-runner/run/incomplete-turn.ts (modified, +46/-1)
  • src/agents/plan-mode/approval.test.ts (added, +270/-0)
  • src/agents/plan-mode/approval.ts (added, +148/-0)
  • src/agents/plan-mode/index.ts (added, +9/-0)
  • src/agents/plan-mode/mutation-gate.test.ts (added, +161/-0)
  • src/agents/plan-mode/mutation-gate.ts (added, +188/-0)
  • src/agents/plan-mode/types.ts (added, +137/-0)
  • src/config/types.agent-defaults.ts (modified, +17/-0)
  • src/config/zod-schema.agent-defaults.ts (modified, +15/-0)

Code Example

exit_plan_mode called
  → plan_approval_requested event emitted
UI renders plan checklist + Approve / Edit / Reject buttons
On Approve: inject approved plan as system message, enter Phase B (normal mode)
On Edit: re-enter Phase A with user's edited plan
On Reject: abort turn
On timeout (configurable, default 10min): auto-reject with message
RAW_BUFFERClick to expand / collapse

GPT 5.4 Enhancement v3 — Phase 3.C

Tracking: #66345 Priority: P1 — The marquee Claude Code-quality feature (opt-in only) Hard depends on: #61845 merging (plan-mode runtime from nick0809cn-ux) Also depends on: #67514 (task-system parity), #67519 (plan rendering)

Context

PR #61845 already builds the plan-mode runtime core:

  • SessionRuntimeMode = "plan" | "normal" | "auto"
  • enter_plan_mode / exit_plan_mode agent tools
  • plan-mode-hook.ts mutation gate (blocks 11+ tool categories)
  • todo_write / task_create / task_update plan-mode tools
  • Session-metadata persistence of plan state

This issue covers the layer above #61845: user-facing entry points and the approval UX that makes plan mode trustworthy. Without this, plan mode is two phases with no human review gate.

Scope

Entry points (all opt-in, never auto-enabled)

  1. Slash command: /plan <optional goal> — one-shot opt-in for the next turn
  2. Config flag: agents.defaults.planMode.enabled: false — per-agent default
  3. Model gate: agents.defaults.planMode.autoEnableFor: [] — regex list (empty by default to preserve Hermes parity)
  4. Control UI toggle: button + keyboard shortcut mirroring Claude Code's Shift+Tab and Codex's /plan

Approval state machine

exit_plan_mode called
  → plan_approval_requested event emitted
  → UI renders plan checklist + Approve / Edit / Reject buttons
  → On Approve: inject approved plan as system message, enter Phase B (normal mode)
  → On Edit: re-enter Phase A with user's edited plan
  → On Reject: abort turn
  → On timeout (configurable, default 10min): auto-reject with message

Channel-native approval UX

ChannelMechanism
Control UIModal with 3 buttons
TelegramInline keyboard buttons (reuses existing approval infra)
DiscordButton row on embed
SlackBlock kit buttons
CLITerminal prompt with 3 options

Tool-name reconciliation

#61845 introduces todo_write / task_create / task_update alongside the existing update_plan. This PR ships an adapter so both tool surfaces produce the same AgentPlanEventData events. Both names resolve to the same handler. Deprecation of one name deferred to Phase 4.

Strict-agentic interaction

  • Phase A: planning-only retry guard is disabled (the whole point is to plan)
  • Phase B: strict-agentic operates normally

Files to create/modify

  • new src/commands/plan.commands.ts
  • src/config/types.agent-defaults.ts, src/config/zod-schema.agent-defaults.ts
  • new src/agents/plan-approval.ts + test
  • src/infra/agent-events.ts (new event types)
  • src/channels/plugins/approvals.ts (extend for plan approval)
  • Control UI approval modal
  • Per-channel approval handlers
  • src/agents/pi-embedded-runner/run/incomplete-turn.ts (bypass guard in Phase A)

Estimated size: ~600 LoC

Open questions (resolve at implementation)

  1. Does "ok do it" during Phase A count as approval → Phase B?
  2. Should exec read-only whitelist be user-editable in config?
  3. Should plan mode block sessions_spawn during Phase A?

Verification

  • gpt54-plan-mode-approve.scenario.yaml — plan → approve → execute
  • gpt54-plan-mode-reject.scenario.yaml — plan → reject → abort
  • gpt54-default-no-plan-mode.scenario.yaml — default GPT-5 does NOT enter plan mode

extent analysis

TL;DR

Implement the plan mode feature by creating the necessary files and modifying existing ones to support user-facing entry points and approval UX.

Guidance

  • Create a new file src/commands/plan.commands.ts to handle the /plan slash command and implement the opt-in functionality.
  • Modify src/config/types.agent-defaults.ts and src/config/zod-schema.agent-defaults.ts to add the planMode configuration options.
  • Develop the approval state machine in src/agents/plan-approval.ts and implement the UI components for plan approval in the Control UI and other channels.
  • Update src/infra/agent-events.ts to include new event types for plan approval and modify src/channels/plugins/approvals.ts to extend the approval functionality for plan approval.

Example

// src/commands/plan.commands.ts
import { Command } from './command';

export const planCommand: Command = {
  name: 'plan',
  description: 'Enter plan mode',
  async execute(ctx, args) {
    // Implement plan mode logic here
  },
};

Notes

The implementation of the plan mode feature requires resolving open questions, such as whether "ok do it" during Phase A counts as approval and whether the exec read-only whitelist should be user-editable in the config.

Recommendation

Apply the workaround by implementing the plan mode feature as described in the guidance section, as the issue provides a clear outline of the necessary steps and files to modify. This will allow for the development of a functional plan mode feature that meets the requirements.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING