- extend provider and orchestration contracts for runtime mode-aware events - persist runtime mode fields in projection thread session storage and migration 006 - update adapters, reactors, projections, websocket/web session logic, and tests - add plan mode deep dive docs and probe artifacts for ACP behavior
20 KiB
Plan Mode Deep Dive
Goal
Understand how the three providers expose:
- planning / read-only execution modes
- structured plan updates
- structured user-input / question prompts
- response plumbing needed for a provider-agnostic adapter layer
Providers covered:
- Codex App Server
- Claude Agent SDK / Claude Code
- Cursor ACP
Existing T3 Code groundwork
Current repo groundwork already exists in these places:
EVENTS.mdpackages/contracts/src/providerRuntime.tsapps/server/src/provider/Layers/CodexAdapter.tsapps/server/src/provider/Layers/ClaudeCodeAdapter.tsapps/server/src/provider/Layers/CursorAdapter.tsapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Canonical runtime events already modeled:
turn.plan.updatedcontent.deltawithstreamKind: "plan_text"user-input.requesteduser-input.resolvedrequest.openedrequest.resolved
This is a good base, but provider coverage is uneven:
- Codex: strong native support for both structured plans and structured user questions.
- Claude: native plan mode exists, but plan updates are mostly implicit via tool/message stream; user questioning appears tool-based rather than a dedicated runtime event.
- Cursor ACP: native plan mode exists, but current ACP surface appears to expose neither structured plan updates nor structured ask-user prompts in the same way as Codex.
Provider 1: Codex App Server
What exists natively
Codex has the richest first-class support for this feature set.
Real local session evidence
The local Codex rollout file confirms at least one important distinction:
- session metadata explicitly records collaboration mode as plan via
turn_context.payload.collaboration_mode.mode = "plan" - final plan handoff is emitted as a normal assistant message containing a
<proposed_plan>block
From the sampled rollout file, I did not find raw event_msg.plan_update / event_msg.plan_delta records, which suggests either:
- this particular session never emitted incremental structured plan updates, or
- the desktop rollout file persists a higher-level message projection rather than every low-level app-server event
That means the app-server protocol still supports native structured plan events, but local rollout files should not be assumed to contain every transport-level plan artifact.
Native surfaces confirmed from upstream docs/source:
- collaboration mode with plan behavior
turn/plan/updateditem/plan/deltaitem/tool/requestUserInputserverRequest/resolvedcleanup / completion notification for user inputrequest_user_inputtool in core/runtime
Evidence inspected:
- upstream
codex-rs/app-server/README.md - upstream
codex-rs/app-server-protocolschemas - upstream
codex-rs/core/src/tools/handlers/request_user_input.rs - upstream
codex-rs/core/templates/collaboration_mode/plan.md
Semantics
Plan mode
Codex plan mode is not just “tool execution denied”. It has explicit behavioral guidance and explicit planning outputs.
Two distinct plan surfaces exist:
-
Structured plan state
turn/plan/updated- payload contains:
- optional
explanation plan: Array<{ step, status }>
- optional
- statuses are
pending | inProgress | completed
-
Plan text stream
item/plan/delta- useful for rendering streaming plan prose / bullet lists before or alongside structured state
This maps very cleanly to our canonical events:
turn/plan.updated->turn.plan.updateditem/plan/delta->content.delta(plan_text)
Structured user questions
Codex has a dedicated request_user_input capability.
Server request:
item/tool/requestUserInput
Shape characteristics from upstream protocol/docs:
- 1–3 questions
- each question has:
- prompt text
- stable id
- required options
- response carries answers per question
- freeform notes are supported in UX and answer model
Important nuance:
- upstream handler currently requires non-empty options for every question
- Codex TUI also supports an optional freeform note / text alongside selected options
- pending question requests are turn-scoped and cleaned up on turn completion/interruption
Why Codex is the reference model
Codex should be treated as the reference shape for our provider-agnostic abstraction because it already matches the desired UI:
- explicit plan lifecycle
- explicit multi-question prompt flow
- explicit answer submission
- explicit pending/resolved bookkeeping
Adapter implications
For Codex, the provider adapter layer should stay close to native protocol:
- keep
turn.plan.updated - keep
content.delta(plan_text) - map
item/tool/requestUserInputtouser-input.requestedandrequest.opened - map answer completion / cleanup to
user-input.resolvedandrequest.resolved
Provider 2: Claude Agent SDK / Claude Code
What exists natively
Claude has an explicit plan permission mode:
Real local session evidence
The sampled Claude session file provides concrete payloads for both key plan-mode tools:
AskUserQuestionappears as a normal assistanttool_useblock with input like:
{
"type": "tool_use",
"name": "AskUserQuestion",
"input": {
"questions": [
{
"question": "What does 'adding profiles to canvas' mean to you? What should profiles enable in canvas?",
"header": "Scope",
"options": [
{ "label": "Organize by profile", "description": "..." },
{ "label": "Profile icon bar in canvas", "description": "..." },
{ "label": "Per-profile canvas settings", "description": "..." },
{ "label": "All of the above", "description": "..." }
],
"multiSelect": false
}
]
}
}
ExitPlanModealso appears as atool_useblock, with a long-formplanstring payload containing the finalized implementation spec.
That gives us two strong adapter conclusions:
- Claude user-input prompting is definitely tool-based and structurally parseable.
- Claude final plan handoff is tool-based too, not necessarily a dedicated transport event like Codex
turn/plan/updated.
Concrete adapter mapping from transcript evidence
Recommended Claude mapping based on real session data:
tool_use.name === "AskUserQuestion"->user-input.requested- user answer submission / tool result ->
user-input.resolved tool_use.name === "ExitPlanMode"withinput.plan-> final plan handoff event or synthesizedturn.plan.updatedsnapshot
The AskUserQuestion payload shape is already close to the UI we want:
questions[]array- each question has
headerandquestion - each question has
options[]withlabel+description multiSelectis explicit
The main remaining unknown is the exact runtime shape of the answer payload that Claude expects back for this tool.
PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk'
Confirmed from installed SDK typings:
/Users/julius/.bun/install/cache/@anthropic-ai/[email protected]@@@1/sdk.d.ts/Users/julius/.bun/install/cache/@anthropic-ai/[email protected]@@@1/sdk-tools.d.ts
Claude also exposes plan-related tools/types:
ExitPlanModeAskUserQuestion
These are strong signals that Claude’s plan UX is built around tool usage within a permissionMode: 'plan' session rather than a dedicated standalone turn.plan.updated event.
What the wire stream exposes
Claude adapter input today is built from SDK messages like:
system:initsystem:statusstream_eventassistantresult- hook/task/tool summary events
The SDK stream exposes:
- message deltas
- tool-use starts/stops via content blocks
- permission-mode metadata
- final result and usage
What it does not appear to expose as a first-class event:
- no direct equivalent to Codex
turn/plan/updated - no direct equivalent to Codex
item/plan/delta - no dedicated top-level
user-input.requestedtransport event in the SDK stream
Instead, plan-mode-related behavior appears to surface through tool uses:
AskUserQuestiontoolExitPlanModetool- regular content/tool stream events
Semantics
Plan mode
Claude’s plan mode is primarily a permission / behavior mode:
- session or turn is created with
permissionMode: 'plan' - tool execution is prevented / constrained
- assistant can explore, reason, and propose a plan
- eventually it may call
ExitPlanModeto transition toward implementation
That means Claude plan mode is native, but structured plan state is not guaranteed.
In practice, there are two likely UI strategies:
- Best-effort structured extraction
- detect plan-like assistant/tool outputs
- synthesize
turn.plan.updatedfrom them
- Text-first plan rendering
- show reasoning / assistant output as plan narrative
- only emit
turn.plan.updatedwhen we can confidently extract steps
Asking user questions
Claude’s AskUserQuestion appears to be a tool, not a dedicated transport-level question request primitive.
That means the adapter likely needs to:
- identify
tool_useforAskUserQuestion - parse its input payload into canonical question schema
- expose
user-input.requested - accept a user answer and feed it back as the tool result / synthetic user response, depending SDK control path
This is adapter work, not just schema plumbing.
Recommended stance for Claude
Claude should support the same canonical user-facing contract, but the adapter will need to manufacture structure from native tool activity.
Recommended mapping:
permissionMode: 'plan'=> canonical session/turn metadatamode = planAskUserQuestiontool use => canonicaluser-input.requested- submitted answer => canonical
user-input.resolved ExitPlanModetool use => canonical state transition or request to continue with implementation- assistant text / tool summaries in plan mode => optional synthesized
turn.plan.updated
Risk / uncertainty
Claude currently appears less deterministic than Codex for structured plans.
Main unknowns to resolve during implementation:
- exact
AskUserQuestiontool input/output payload shapes at runtime - whether freeform responses are supported natively or need synthetic augmentation
- whether
ExitPlanModeshould be exposed to UI explicitly or handled internally by the adapter/session controller
Provider 3: Cursor ACP
What exists natively
Cursor ACP does have native session modes.
Confirmed by local probe output in .tmp/acp-plan-probe/summary.json:
agentplanask
The probe also confirmed current primary ACP update surfaces:
available_commands_updateagent_thought_chunkagent_message_chunktool_calltool_call_updatesession/request_permission
What the probe did not find
The existing probe did not surface:
- structured plan update events
- a dedicated “ask user question” request
- a dedicated plan delta stream
The current ACP surface therefore looks much thinner than Codex.
Semantics
Plan mode
Cursor plan mode clearly exists as a session mode, but as currently observed it seems to mean:
- read-only / design-first behavior
- regular thought/message chunk streaming
- no dedicated structured plan payload
So the plan is native as a mode, but not obviously as a structured protocol surface.
Asking the user questions
Cursor ACP currently gives us a nearby primitive only for permission requests:
session/request_permission
That is not the same as product-level question asking.
The existence of ask mode suggests Cursor may handle asking by:
- normal assistant prose in ask mode
- possibly mode-switch semantics
- possibly skills/commands that we have not yet triggered
But based on current probe evidence, we should not assume a Codex-style structured question API exists in ACP.
Recommended stance for Cursor
Treat Cursor as:
- native support for
mode = plan - no proven native support for structured plan steps
- no proven native support for structured user-input questions
Therefore Cursor likely needs the most adapter synthesis:
- derive plan-mode state from ACP session mode
- optionally synthesize
turn.plan.updatedfrom assistant text if we can extract steps safely - for interactive questions, likely fall back to regular conversational turns unless a richer ACP mechanism is discovered
Important product implication
If we want the same rich “multiple-choice question card” UX across all providers, Cursor may need one of these paths:
- Provider-native path if later ACP exploration finds structured user question primitives
- Adapter-mediated path where the provider is instructed to emit a machine-readable question block in text and adapter parses it
- Capability downgrade where Cursor only supports conversational follow-up, not full structured plan-question cards
Today, evidence supports option 3 as the safe baseline.
Cross-provider comparison
Capability matrix
| Capability | Codex App Server | Claude Agent SDK | Cursor ACP |
|---|---|---|---|
| Native plan mode | Yes | Yes | Yes |
| Structured plan update event | Yes | Not obvious / likely no | Not observed |
| Plan text delta stream | Yes | Not first-class | Not observed |
| Native structured user question API | Yes | Tool-based, likely yes-ish | Not observed |
| Native answer resolution lifecycle | Yes | Likely adapter-mediated | Not observed |
| Best provider for canonical contract | Strong | Medium | Weak |
Core insight
“Plan mode” means different things across providers:
- Codex: plan mode is a first-class runtime concept with structured plan and question surfaces.
- Claude: plan mode is a first-class permission mode, but structured plan/question UI likely needs adapter interpretation.
- Cursor: plan mode is a first-class session mode, but richer plan/question structure is not currently exposed.
Recommended provider-agnostic contract
We should separate three concerns that are currently easy to conflate.
1. Session / turn mode
A canonical mode flag:
defaultplanaskexecuteunknown
This is about agent operating mode, not UI widgets.
2. Structured plan state
A canonical plan model:
interface CanonicalPlanState {
explanation?: string | null;
steps: Array<{
id?: string;
text: string;
status: 'pending' | 'inProgress' | 'completed';
source: 'native' | 'synthesized';
}>;
}
Rules:
- Codex can populate this natively.
- Claude/Cursor may populate it only when extraction is confident.
- UI should tolerate absence of structured plan state.
3. Structured user-input prompt
Canonical prompt should be modeled independently of approvals:
interface CanonicalUserInputPrompt {
promptId: string;
title?: string;
description?: string;
questions: Array<{
id: string;
label: string;
description?: string;
options: Array<{
id: string;
label: string;
description?: string;
recommended?: boolean;
}>;
allowFreeform?: boolean;
freeformPlaceholder?: string;
required?: boolean;
}>;
source: 'native' | 'tool-derived' | 'synthesized';
}
And answers:
interface CanonicalUserInputAnswer {
promptId: string;
answers: Array<{
questionId: string;
selectedOptionId?: string;
text?: string;
}>;
}
Why separate request.opened from user-input.requested
Because they are not the same abstraction:
- approvals = “may I run/edit/do X?”
- user-input prompts = “which direction do you want?”
Codex already blurs these at transport level because item/tool/requestUserInput is a request.
But product and UI should keep them separate.
Recommended rule:
- keep
request.opened/request.resolvedfor transport-level correlation - keep
user-input.requested/user-input.resolvedfor product-level UX
Adapter strategy by provider
Codex adapter
Use native primitives directly.
Implementation target:
- preserve
turn.plan.updated - preserve
content.delta(plan_text) - preserve
user-input.requested - preserve
user-input.resolved - expose raw/native metadata for future UI improvements
Claude adapter
Implement tool-aware adaptation.
Implementation target:
- treat
permissionMode: 'plan'as native plan-mode state - detect
AskUserQuestiontool uses and convert to canonical user-input prompt - convert question answers back into Claude-native tool response path
- detect
ExitPlanModeand emit a canonical mode-change / handoff event - optionally synthesize plan steps from assistant output in plan mode
Cursor adapter
Implement conservative degraded support first.
Implementation target:
- expose native session mode including
planandask - do not claim structured plan updates unless proven
- do not claim structured user-input prompts unless proven
- optionally add a provider capability flag so UI can fall back to conversational follow-up
Capability flags we should add
To avoid overpromising in the UI, add provider runtime capabilities such as:
interface ProviderInteractiveCapabilities {
supportsPlanMode: boolean;
supportsAskMode: boolean;
supportsStructuredPlanUpdates: boolean;
supportsPlanTextStreaming: boolean;
supportsStructuredUserInput: boolean;
supportsFreeformUserInput: boolean;
supportsExitPlanMode: boolean;
}
Expected initial values:
- Codex: all or nearly all
true - Claude:
supportsPlanMode=true,supportsStructuredUserInput=likely true via adapter,supportsStructuredPlanUpdates=partial - Cursor:
supportsPlanMode=true,supportsAskMode=true, most structured flagsfalse
This lets the UI:
- render rich plan cards only when supported
- fall back to plain assistant text + reply box otherwise
- avoid coupling the design to Codex-specific assumptions
Suggested implementation order
- Formalize provider capability flags
- make support explicit before UI work
- Finish canonical user-input contracts
- question schema, answer schema, source markers
- Codex end-to-end implementation first
- closest match to desired UX
- Claude adapter translation second
- parse
AskUserQuestionandExitPlanMode
- parse
- Cursor degraded plan-mode support third
- mode awareness first, richer structure later
- UI renders by capability, not provider name
- prevents provider-specific branching from leaking upward
Open questions
- Claude runtime payloads:
- what exact
AskUserQuestioninput/output shapes arrive over the stream?
- what exact
- Claude answer submission path:
- should answers be injected as tool results, control responses, or synthetic user turns?
- Cursor ACP:
- is there an undocumented or less common interactive prompt primitive beyond
session/request_permission?
- is there an undocumented or less common interactive prompt primitive beyond
- Cursor mode switching:
- can ACP session mode change mid-session, and is that surfaced as
session/updateor request/response only?
- can ACP session mode change mid-session, and is that surfaced as
- Plan synthesis:
- do we want best-effort extraction of numbered/bulleted plans into
turn.plan.updatedfor Claude/Cursor, or should we keep structured plans native-only at first?
- do we want best-effort extraction of numbered/bulleted plans into
Immediate recommendation
Build the product contract around capabilities, not around the assumption that every provider has Codex-style plan/question primitives.
Concretely:
- Codex should drive the first full UX implementation.
- Claude should be supported with adapter-derived question handling and partial/synthesized plan state.
- Cursor should initially support mode-aware UX with graceful fallback to conversational replies rather than full structured question cards.
That gives us a provider-agnostic architecture without pretending the underlying protocols are already equivalent.