The master merge brought the tool registry's per-scope restriction layer (tools.restrict), which makes dsh-mode's prepend assemble filter a duplicate enforcement shape: it re-implemented the registry's SDK-section rendering (renderToolsSdk + the RUN_CODE_NAME exclusion) and hid the exit tool from prompts only — dispatch stayed open and the execute-time re-check was the real gate. The service now reconciles a per-agent deny restriction on agent.ctx at agent/created and at every boundary flush, so wire schemas, the Code Mode tools:sdk section, AND dispatch resolve exit_plan_mode through the one registry view (a default-mode call answers UNKNOWN_TOOL, byte-identical to a no-dsh-mode deployment). The execute-time folded-mode re-check stays as defense in depth for a direct foreign mode/set append no boundary has reconciled yet. Two zero-consumer surfaces removed per the pre-release stance: - AgentOptions.mode creation seeding (declaration merge + agent/created listener); a caller selects through set() before the first turn, and the deferred subagent inheritance returns together with its consumer. - The dropped-definition boundary notice (droppedNoticed + narration): custom mode definitions have no production consumer, so nothing can be dropped; fold-to-default degradation is unchanged. The stdio removal had left plan mode ACP-only while docs still claimed a /mode command. dsh-mode now registers /mode on the plugin-owned command registry through an optional ctx.inject(['commands']) child (type-only peer edge on dsh-commands), so the TUI and the ACP slash-command surface both gain it; examples/tui-agent composes dsh-mode. ACP/TUI expected outputs refreshed keyless for the available_commands_update delta. Docs updated in place (mode READMEs, the plan-mode Agent Note's realization sections); catalogs and graphs regenerated.
36 KiB
Agent Note: Plan mode — a logged per-agent session mode
Status: implemented
Problem
The harness has no way to put an agent into a distinct working stance. The canonical feature that needs one is plan mode — the agent explores and designs under a planning stance, produces a reviewable plan, and crosses back through an explicit approval. The extension cookbook already reserves the row ("Plan mode — tools/pre-execute (deny writes) + a mode prompt section"), and the ACP feature matrix records session modes as a known gap both reference adapters ship. Neither says where the mode STATE lives, how it survives resume and fork, or how its model-visible consequences stay honest with the session log.
Every shipped plan mode decomposes into the same five parts — a low-authority tool policy, a plan artifact, an approval moment, an execution-state switch, and durable state (Prior art carries the survey). Four of the five already exist here as gated infrastructure: what the model is TOLD it can do is shaped per step at system-prompt/assemble and whatever ships is logged as request/header* events (reconstructability); what can RUN is gated at tools/pre-execute with typed decisions (interception seams); the approval moment is a human answer over the user-interaction seam (ctx.userInteraction, the ask-user precedent); durable per-agent facts are SessionEventMap members (the todo/write precedent). The missing fifth is the mode itself: a named, durable, per-agent state its listeners can read.
Decision
The deliverable is plan mode. It ships as the first session mode — a named, logged, per-agent COLLABORATION state: a mode definition is the guidance section the model sees, deployment config; the mode IN FORCE for an agent is session state, folded from its log. Modes are one axis and the enforcement knobs — the sandbox mode, the approval policy — are others: they never read or write each other, matching how Codex keeps its Plan/Default collaboration presets separate from its sandbox and approval settings. One new product package, @deepseek-ai/dsh-mode at packages/mode/mode/ (a new top-level group, the packages/approval/ shape), owns the event vocabulary, a thin ctx.modes service, and every listener; the loop does not change. plan is the only shipped definition — the mode-shaped vocabulary exists so a second mode never renames durable event types, not because more modes ship now.
The state is one SessionEventMap member: mode/set, a log-only, non-surface event carrying { mode: string } with whole-value-replace semantics, plus a pure foldMode(events) that returns the mode in force — the last mode/set, or the default mode when none exists. Because the log is the fact channel, resume, fork, and compaction restore the mode with no extra machinery, and UIs read flips off session/event. The default mode is the absence of policy — no section, no filtering, no gate — so loading dsh-mode alone adds no default request bytes and is safe to compose unconditionally.
A mode's whole surface is soft: a system-prompt/assemble listener renders the mode's guidance section and shows the exit_plan_mode tool IFF the folded mode is plan — every transition therefore surfaces as an attributable complete request/header event on the next step, keeping the reconstructability invariant green by construction. A mode deliberately enforces NOTHING: no execution gate, no tool filtering, no reach into the sandbox or approval knobs — a user who wants a hard read-only floor while planning switches the sandbox-mode option beside the mode picker, in either order, and neither axis disturbs the other. There is likewise NO per-mode tool allow/deny list — which tools a mode admits is an effects question, parked until tool definitions declare their effects (Deferred); a mode's restraint is its section's guidance plus the exit review.
The model leaves plan mode through the exit_plan_mode tool: its single argument is the plan text, which makes the plan a durable log artifact, and the tool conducts the review itself through the user-interaction seam — a question with options and a free-text channel, not a bare permission — so an approval flips the logged mode back to the default, and a rejection becomes the corrective error carrying the user's feedback verbatim, which keeps the model planning with direction. A user flips the mode from any surface through ctx.modes.set(); the flip is applied at the next turn boundary (session events are turn-enclosed) and narrated to the model once, only when the model-visible state actually changed.
High-level API
A plan-mode session end to end
The user switches the session to plan mode — the ACP mode picker or the /mode plan command in a terminal front door — and from the next turn every request ships the plan guidance section and the exit_plan_mode tool.
The model explores and designs; the section's guidance is what defers changes into the plan. The sandbox and approval knobs keep whatever the user set them to — a deployment (or user) that wants kernel-enforced read-only during planning pairs plan mode with the independent sandbox-mode option.
When ready, the model calls exit_plan_mode with the plan markdown as its argument; the UI renders the plan as the call card and the review question arrives through the user-interaction channel — approve, or keep planning, with free-text feedback welcome — so what the human reviews is exactly the logged artifact.
On approve, the tool flips the logged mode back to the default: the next step drops the plan section and the exit tool (the header event is in the log), and execution tracking from there is already todo_write's job. On keep-planning, the model receives a corrective error carrying the user's feedback text, revises, and re-presents.
Deployment configuration
Mode definitions are validated plugin Config — per repo convention, changeable from cordis.yml with no code edit. The shipped plan definition works with zero config; overriding it, or adding a mode, is a config entry:
- id: mode
name: '@deepseek-ai/dsh-mode'
config:
modes:
plan:
section: |
You are in plan mode: explore and design, then present the
plan for approval through exit_plan_mode.
A definition is exactly { section } — there is deliberately no per-mode tool list and no enforcement field (FAQ). default is reserved (the absence of policy) and rejected as a key; any unknown definition key — a tools list or an access cap included — fails validation at load; an unknown mode name fails loudly at set() time.
In the terminal
Terminal front doors get /mode through the plugin-owned command registry (@deepseek-ai/dsh-commands): dsh-mode registers the command when a commands service is composed — bare /mode prints the current and available modes, /mode <name> records the switch (a command line, never sent to the model). The exit review prompts right in the terminal with no new machinery: it is an ordinary user-interaction question, so it rides the composed user-interaction provider's prompt queue that ask_user_question already uses.
Over ACP
The mode PICKER is this package's surface: session/new/session/load advertise availableModes/currentModeId from ctx.modes (consumed opportunistically via ctx.get, the tool-bash pattern), session/set_mode calls set() and notifies current_mode_update optimistically (the pending mode IS the user's selection; the logged mode/set follows at the boundary), and a session/event listener re-notifies on each logged flip that differs from the last sent. The exit tool's review needs no new ACP work at all — it rides the elicitation flow the user-interaction ACP provider already drives, beside the already-streamed plan card. Individual environment knobs — sandbox mode, approval policy, the model — are NOT modes and belong to session/set_config_option (FAQ).
For agent creators
ctx.modes is the whole programmatic surface: list() returns the configured definitions plus the synthetic default entry (for pickers), get(agent) returns the folded mode plus any pending intent, and set(agent, mode) validates the name against list()'s vocabulary and records the boundary-applied intent — default is always a valid target, so exiting a mode is the same call as entering one. There is no creation-time mode option — a caller selects through set() before the first turn, which flushes identically. There is no live agent/* mirror to subscribe: UIs read mode/set off session/event, per event-domain semantics.
Detailed design
Vocabulary
'mode/set': { mode: string } // SessionEventMap merge in dsh-mode: log-only, non-surface,
// whole-value replace — the last one in the log wins
DEFAULT_MODE = 'default' // the fold of a log with no mode/set; reserved, not definable
The payload carries no reason/provenance field: a tool-driven flip sits next to its tool/call in the log and a user flip sits at its turn boundary, so the cause is log-adjacent — the same "narrative fields are derivable" call the reconstructability Agent Note made for header deltas (the in-flight env/state event carries a source precisely because its drift variant has NO log-adjacent cause — a contrast, not a conflict). Mode names are config-declared vocabulary, not opaque cross-boundary ids, so they stay bare strings (no Branded<B>).
Config and the resolve step
interface ModeDefinition { section: string } // prompt text — a mode's whole vocabulary
interface ModeConfig { modes?: Record<string, ModeDefinition> } // plan's built-in definition merged unless overridden
resolveConfig(config): ResolvedModes // explicit resolve (the dsh-bash template), fail-loud:
// 'default' as a key rejected; any unknown key rejected
The one-field shape is deliberate minimalism, not the final vocabulary: a per-tool policy dimension returns as effects metadata on tool definitions (Deferred), read here rather than re-declared per mode — the config shape must not need a migration when it arrives.
The fold, the service, and the flush
foldMode(events) is pure (exported for reconstructors and tests); the service tracks it per session with a lazy cursor in a WeakMap<Session, { cursor, mode }> — O(new events) per read, never invalidated, because the log is append-only and mode/set is not a surface node (compaction cannot rewrite it). set(agent, mode) validates the name against list()'s vocabulary — the configured definitions plus the reserved default, which is rejected as a config KEY but always accepted as a set() TARGET (a picker's exit-to-default must be a valid write) — drops a no-op (target equals pending ?? current), and otherwise records the intent in a WeakMap<Session, string> — it cannot append immediately, because every session event is turn-enclosed and an idle agent has no open turn.
Contained listeners on the loop's interception seams (defensive patterns: a policy plugin must not block a prompt or a turn) flush the pending intent as a mode/set append — agent/prompt-submit fires inside the just-opened turn before its first assembly, agent/turn-continuation after each step closed before the next assembly, and both sit outside the step's tool-execution window AND outside any log emit (post-commit session/event observers are observe-only; an append from one would re-enter the publishing append), so the executions of a step always run under the mode its assembly folded. When the flushed mode differs from the fold at the last request/header, the flush appends one coalesced context/message notice in the same frame ("The user switched this session to plan mode."); the user-visible narration cases are enumerated in the FAQ.
The soft layer: a computed section and a narrow post-next() filter
A system-prompt/assemble waterfall listener reads the calling agent's mode (the AssembleContext carries agent) and, in a non-default mode, appends the mode's guidance section. The loop already renders per step and logs the result: entering or leaving a mode surfaces on the next step as a complete changed request/header, so every mode transition is an attributable log fact. The section is static per mode and the plan itself stays in the conversation (messages and tool args, already in context), so a mode does not add per-step prompt churn — re-injecting plan state into every request (Prior art's compaction-survival hack) is unnecessary and would only burn prefix cache.
The guidance section is an ordinary registered section, { name: 'mode:policy', order: 50, text: context => … } — order 50 sits after the persona (0) and before tool guidance (100–199); it resolves to the folded mode's configured text and to '' (dropped at render) for the default mode or an agent-less assembly. The ONE tool rule this plugin has rides the registry's scoped restriction layer, not an assemble wrapper: outside plan the service holds a per-agent deny restriction over exit_plan_mode (agent.ctx.tools.restrict), reconciled with the fold at agent/created and at every boundary flush, so wire schemas, the Code Mode tools:sdk section, and dispatch all resolve the tool through the one registry view — a default-mode assembly is byte-identical to a no-dsh-mode deployment, and a default-mode dispatch answers unknown tool at the registry boundary rather than relying on prompt omission. Everything else passes through untouched: which tools a mode admits is not this plugin's decision. There is NO tools/pre-execute listener: the restriction plus the exit tool's own folded-mode recheck (defense in depth for a direct foreign mode/set append no boundary has reconciled yet) cover the exit tool, and the registry's ask vocabulary stays free for genuine permission gating — the exit review is a question with options and feedback, not a permission, so it lives inside the tool's own execution over the user-interaction seam.
exit_plan_mode
defineTool with one required plan: string argument — the plan is thereby a durable, replayable log artifact riding the ordinary tool/call event. execute rejects an agent-less call (the todo_write precedent), re-checks the folded mode as defense in depth, then conducts the review: one single-select ctx.userInteraction.ask() question — approve, or keep planning — with the free-text channel open for feedback. Approve records the switch back to default as a SILENT boundary-applied pending intent (flushed at this step's end, still in-turn) and returns a short confirmation; the plan surface — the section, the exit tool's visibility — therefore keeps holding for every remaining call of the SAME assistant response (they were requested under the plan-shaped header), and the next step reflects the exit, logging the pure-removal header-delta. Every other outcome — keep-planning (the user's feedback text carried verbatim), an aborted question, a missing provider — returns the corrective isError that tells the model to revise and re-present, and the mode stays plan.
Its render intent, decided up front: presentCall is a generic card titled by the plan's first heading with the plan markdown as content, plus a generic result card — the review question arrives beside this already-streamed card, so what the human reviews is exactly the logged artifact. The seam is consumed opportunistically (ctx.get('userInteraction')), so dsh-mode composes without it and degrades to the manual exit pinned in the FAQ.
Dependencies and surfaces
dsh-mode is one product package, not a capability-seam trio (Alternatives considered): it peers on cordis, dsh-session, dsh-agent, dsh-tools, and dsh-system-prompt, injects ['tools', 'systemPrompt'], and reads ctx.userInteraction opportunistically at execute time (a type-only peer edge on dsh-user-interaction); its only UI-facing edges are optional type-only peers (dsh-commands for /mode). Beyond the ctx.modes call surface everything participates through listeners, so dropping the package gracefully removes modes rather than breaking a consumer. Terminal front doors need no mode-specific code: dsh-mode itself registers /mode on the command registry when one is composed (an optional type-only peer edge on dsh-commands), and the exit review rides the composed user-interaction provider's prompt queue. The ACP wire mapping is pinned in High-level API; package-wise the bridge takes a type-only peer edge on dsh-mode and reads the service opportunistically, so a bridge without the plugin behaves exactly as today.
The recorded scenario and the harness op
input.json gains one step op, { "op": "setMode", "modeId": "plan" }, driven through the real session/set_mode RPC, and a scripted elicitationAnswers queue (FIFO, consumed by the harness client's elicitation callback — the review question's answer). The plan-mode scenario: initialize → newSession → setMode(plan) → a prompt the model answers by running a real cat through the bash tool INSIDE plan (the composition's sandbox applies exactly as in default mode; on replay the command re-executes under the host runner — Seatbelt on macOS, bwrap on Linux CI) and presenting the plan via exit_plan_mode → a scripted approve → the same turn's next step edits for real. Because the mode is set before turn 1, the FIRST request/header snapshot is already in plan shape (the full toolset plus the exit tool, the mode section, reason initial); the approved exit logs a complete changed request/header, and the scenario pins both, plus the mode/set pair. A sibling plan-mode-reject scenario scripts the keep-planning answer with feedback text and pins the corrective result. Both need a with-key recording session; the sandbox-denial marker, whose recorded stderr would be the backend's dialect and replay only where it was recorded, stays pinned at dsh-tool-bash's unit tier.
The mechanical tail
No new cordis event is declared (mode/set rides session/event; the listeners attach to existing waterfalls), so the events catalog is untouched. Regenerated in the same change: the persistence log catalog (mode/set), the services catalog (ctx.modes, JSDoc-complete), the config catalog (ModeConfig), the tool catalog (exit_plan_mode), the producer/consumer map and doc graphs, and the module graph. Repo plumbing: a root tsconfig paths entry, the new group's README plus a packages map row (a new top-level group is the deliberate act that table names), an architecture.md capability-services row for ctx.modes (budget-checked), and the cookbook row upgrade.
Deferred
Each behind its own decision: subagent mode inheritance via a forwarded creation-time mode option (removed as unconsumed; it returns with its first consumer), preset modes beyond plan (read-only, accept-edits), the idle-record primitive if pending-intent loss proves real, and — the big one — effects self-declaration on tool definitions: a per-tool read-only/mutating classification (the MCP ToolAnnotations vocabulary — readOnlyHint/destructiveHint — is the natural template, with its untrusted-hint caveat implying trust tiers). That item is what a general per-mode tool policy waits on: this Agent Note first shipped an interim per-mode name allowlist and removed it before release — a hand-maintained list mislabels the effects question, must track every tool a deployment composes, and rots silently as tools arrive — so mode-scoped tool availability (and per-tool ask policies) returns as a CONSUMER of declared effects, which is its restart trigger.
The canonical examples/acp-agent composition mounts the mode and question-tool plugins on the full ACP coding server; plan mode is an additive session feature, not a second server profile. Its existing snapshot suite owns the landed scenarios: plan-mode (the pinned-header arc — plan-shaped initial header, a real cat inside plan, scripted elicitation approve, the pure-removal header-delta, a real edit) and plan-mode-reject (keep-planning feedback carried verbatim in the corrective isError), beside the keyless modes-advertise wire golden.
FAQ
Behavioral clarifications of the chosen design; rejected designs live in Alternatives considered, accepted costs in Consequences.
When does a user's mode flip take effect? At the next turn boundary: set() records a pending intent, the service flushes it as the first append after the next turn/start, and the loop assembles the prompt after the turn opens and before each step — so step 1 already folds it. A mid-turn flip lands at the next boundary and takes effect on the following step. This is the "applies to subsequent requests" semantics every product in Prior art ships.
When is a mode change narrated to the model? Only when the model-visible state actually changed: the flush compares the flushed mode against the fold at the last request/header and narrates once, coalesced. A net-zero flip sequence (plan then back, all before the boundary) narrates nothing; a tool-driven exit narrates through its own tool result instead; a mode set before the first turn narrates nothing — the section is the state statement. The principle is the in-flight env-state proposal's boundary narration: a silently flipped prompt surface leaves the transcript arguing from a state the header no longer has.
What happens on resume when the config no longer defines the folded mode? One read-path rule closes the gap: a folded mode name the current config no longer defines behaves as the default mode — never a silent substitute restriction, never a bricked session. (A dedicated boundary notice narrating the dropped definition shipped first and was removed as speculative: custom mode definitions have no production consumer yet, so nothing can currently be dropped; it returns with its first consumer if silent degradation proves confusing.) set()'s loud validation covers only the write path; a resumed log answers to the config it finds.
What if a deployment composes no user-interaction provider? Plan mode stays safe but manual: ctx.userInteraction.ask() throws NO_PROVIDER (and an absent seam never resolves at all), the tool returns the corrective isError, and the exit degrades to the user toggling modes — never to an unreviewed exit. The mode section tells the model to present its plan through exit_plan_mode — and to ask the user in prose if that fails — so it keeps presenting instead of stalling.
Why is there no per-mode tool allowlist? Because "which tools are safe in a planning mode" is a property of each TOOL (its effects), not of the mode — a per-mode name list re-declares that fact in the wrong home, must enumerate every tool the deployment composes (MCP servers included), and rots silently as tools arrive. Until tool definitions declare their effects (Deferred, where the removed interim allowlist is archived with its restart trigger), a mode restrains by its section and the exit review; the exposure is an accepted cost (Consequences).
Do subagents inherit the parent's mode? A fork child inherits for free — the parent's mode/set is inside the seeded prefix. A spawn child starts in the default mode; a creation-time mode option and automatic forwarding by subagent providers are deferred together (Deferred).
How does plan mode relate to the sandbox's read-only mode? They are separate axes that never touch: the mode is the collaboration stance (a mode/set fold), the sandbox mode is an enforcement knob (a bash/sandbox-mode fold, the sandbox Agent Note) — plan mode neither reads nor caps it, exactly as Codex keeps its Plan/Default presets separate from its sandbox and approval settings. A user who wants kernel-enforced read-only while planning sets both: flip the mode picker AND the sandbox-mode option, in either order; each switch changes only its own fold, so there is no interference and no restore step to crash out of. The log attributes each axis to its own event — the stance to mode/set, the confinement to bash/sandbox-mode.
Why aren't sandbox mode, approval policy, or the model themselves modes? They are individual environment knobs and belong to ACP's session/set_config_option; the division this proposal pins is picker-to-modes / knobs-to-config-options, recorded in the feature matrix now that both this stack's picker and the sandbox stack's config options are landed. A mode definition may later bundle env facts (applied through ctx.envState where mounted) so a Codex-style preset stays a single mode; fusing approval policy into the mode CONCEPT itself is rejected in Alternatives considered.
Prior art
A survey of shipped plan modes (Claude Code, Cursor, Copilot, OpenCode, Gemini CLI, Cline, Windsurf, Codex) shows the same five parts everywhere — the low-authority tool policy, plan artifact, approval moment, execution-state switch, and durable state that Problem builds on.
The mode surface is a LIST everywhere it is advertised, never a boolean: Claude Code's picker offers plan beside acceptEdits (plus an auto-mode entry into plan), and Codex exposes Plan beside Default as collaboration-mode presets while keeping approval and sandbox settings separate. This is the surface the ACP feature matrix records as the gap, and what sizes the vocabulary as named modes rather than a flag.
The ecosystems that leave modes to convention show the failure shapes to avoid. Pi-style mode extensions fight over a last-wins global active-tool list, enforce "read-only" by prompt text alone (a hallucinated call to a still-registered tool executes), and re-inject plan state into every request to survive compaction. The contested global list and the re-injection hack close structurally here — per-agent folded state, and a log-only non-surface event compaction cannot shadow. The prompt-only shape, by contrast, is deliberately KEPT — it is what Codex ships for Plan, and it is why the mode axis composes freely with the enforcement axes: a deployment that wants a hard floor pairs the mode with the independent sandbox knob instead of the mode carrying its own enforcement (FAQ).
Alternatives considered
Permission modes as the concept (the Claude Code shape). One permissionMode fusing approval policy and tool policy. Here those are two axes with two owners: the approval seam owns "who answers this question", modes own "what surface does the model get". ACP models them as related but distinct (a mode may select an approval policy later — a mode definition gains a field, not a merger).
A capability-seam trio. Interface/implementation/consumer fits a swappable backend; a mode's variable parts are config values, not implementations. Splitting would manufacture an empty implementation package — the same "don't split preemptively" call the approval seam and todo/ made.
Loop-owned mode state. Rejected on the standing rule (plugins, not loop changes): every hook the feature needs — assemble, pre-execute, turn boundaries, session events — is already a documented seam, so a loop edit would buy nothing but coupling.
A per-mode tool allowlist with a deny-by-default gate (the first shipped shape). Removed before release. A hand-maintained name list re-declares a per-TOOL fact (its effects) per MODE: it must enumerate every tool the deployment composes — MCP servers and future registrations included — and it rots silently as tools arrive (a new read-only tool is blocked until someone edits every mode; the author burden lands on whoever knows the mode, not whoever knows the tool). It also over-promises: the list looks like a security boundary while the real boundary for anything non-shell does not exist. The general dimension is parked on effects self-declaration (Deferred); the consequence — plan mode is guidance-only, the very Pi hole the gate once closed — is accepted deliberately, priced in Consequences.
An access sandbox cap on the mode (the second shipped shape). Also removed before release. ModeDefinition.access clamped the bash seam's per-call sandbox resolution to a mode-declared ceiling (a bash/resolve-mode waterfall + ladder-min listener, with guards withholding bash under an unconfinable executor and denying escalation mid-mode). The state stayed orthogonal — the clamp never wrote the sandbox knob — but the AXES did not: entering plan changed what the sandbox enforced, fusing the collaboration stance with an enforcement level and contradicting the Codex-shaped separation the review converged on (Plan/Default presets never touch sandbox or approval settings). One user-visible symptom of the fusion: flipping the sandbox option to workspace-write while planning silently did nothing. The cap, the waterfall, and the mode→bash dependency edge were removed together; a deployment gets kernel-enforced read-only planning by pairing the mode with the independent sandbox-mode option, and a mode-triggered PRESET (a mode definition bundling suggested knob values, applied as ordinary knob switches) can return later without re-fusing the axes.
Runtime-only mode (UI- or bridge-local, unlogged). Resume and fork would silently drop the mode, and the header deltas a mode causes would have no attributable cause in the log. Logged state is what makes the mode auditable and restorable for free.
Mode flips as context/message via agent.inject(). Reuses an existing turn-enclosure path, but puts policy state into the model transcript — the model does not need to be told twice (the section already tells it), and a log-only fact should not occupy surface.
A plan-file store (.plans/ directory). A second durable home for what the log already carries replayably; a deployment wanting files can add a tool that writes them. One home per fact.
A boolean planMode instead of named modes. Too narrow for the surface the repo already tracks: ACP advertises a mode LIST and the shipped pickers fill it with more than plan (Prior art); generalizing later would rename durable event vocabulary. The string-shaped mechanism costs nothing extra now; only plan ships as a definition.
A tool-policy-stack service (the Pi-critique remedy). A dedicated composition service for tool policies is premature: waterfall listeners compose by construction, and the narrow surface this plugin filters (exactly the exit tool) makes filter-order races non-exploitable. Formalize only if real conflicts appear.
Exit approval through the approval seam (a { kind: 'ask' } gate decision). The original sketch, natural while the approval seam was the only asking machinery in flight — but it seats a review in a permission chair: the seam's outcome vocabulary is deliberately closed and one-shot (allowed-once/rejected), so a rejection carries no feedback and an approval can never grow options (approve-and-accept-edits). The exit moment is a question, not a permission — the user-interaction seam gives it options plus the free-text channel, and the rejection feedback reaches the model verbatim. The approval seam remains the right seat for genuine permission gates (the sandbox escalation), and the registry's ask vocabulary stays available to deployments that want one there.
Exit by prose or steering instead of a tool. No artifact and no approval moment — the tool's argument IS the reviewable plan, and its review question is what gives the human a structured yes/no attached to the exact transition.
Consequences
What holds now, pinned by the unit, protocol, and snapshot tiers:
- The mode in force is a pure function of the session log: resume and fork restore it with no extra machinery, and a
mode/setis followed by the matching completerequest/headerevent on the next step with the dev invariant green throughout. - A user-driven flip narrates exactly once at the next boundary and a net-zero flip sequence narrates nothing; a tool-driven exit narrates only through its tool result.
- In the default mode
dsh-modeitself is invisible: assemblies are byte-identical with and without the mode plugin; independently composed tools remain present in both modes. - In plan mode the guidance section and the
exit_plan_modetool reach both the wire request and the logged header; entering and leaving plan each log a complete header snapshot. - Plan mode changes nothing on the enforcement axes: the toolset, the sandbox mode, escalation, and the approval policy behave identically in plan and default — pairing the mode with the independent sandbox/approval knobs is how a deployment hardens planning.
- Mode definitions (section text) are changeable from
cordis.ymlwith no code edit; an unknown mode name fails validation loudly atset()time, an unknown definition key at load. exit_plan_mode's approve path flips the mode and drops the plan surface on the next step; the keep-planning path returns the correctiveisErrorcarrying the user's feedback and stays in plan mode; the ACPsession/set_moderound-trip updatescurrent_mode_update, and the exit review prompts through each surface's user-interaction provider.- The docs tail shipped with the landing: READMEs, regenerated catalogs (persistence log, config, cordis services, tools), the packages map and architecture rows, and the cookbook row.
The accepted costs: a pending user flip set while idle is lost if the process dies before the next turn (the UI re-applies; the idle-record primitive is the escape hatch if this bites in practice). Every mode transition is a logged header change and therefore a prefix-cache reset at the provider — inherent, visible in per-step usage, and an argument against mode-flapping UIs, not against the design. A mode restrains by guidance alone: a model that ignores the section CAN mutate during plan — the review moment, the session log (every call attributable under the plan-shaped header), and the independent enforcement axes (the sandbox mode, the approval policy, the fs stack's own policies) are the containment surface, and hardening planning means setting those knobs, not widening the mode; the two removed enforcement shapes and their restart trigger (effects self-declaration) are archived in Alternatives considered and Deferred. The exit tool's visibility is a registry restriction, so an assemble listener cannot re-show it; the executor resolves dispatch through the same view. The ACP mode surface carries both this stack's picker and the sandbox stack's config options under the picker-to-modes / knobs-to-config-options division pinned in the FAQ, recorded in the feature matrix. The ACP spec's draft v2 direction reportedly slates session modes for removal in favor of config options; if that lands, the picker migrates to a config-option select mechanically — the mode state and every policy surface are wire-agnostic — accepted.