Asking the human: ask and plan mode

Part of the Workflow Modes reference.

Talking to the human: ask, enter_plan_mode, exit_plan_mode

Three tools let the agent involve you deliberately instead of guessing or stopping. They ship with the extension and need no configuration.

ask

Puts a question to you mid-task and waits. Offer-options questions render as a picker; open questions as a text box. Either way a “Let me answer in my own words” choice is always present, because the agent’s two options are frequently a false dichotomy and the real answer is a third thing. Available in every mode — clarification is not a planning activity, and an agent midway through an implementation that hits a genuine fork should not have to stage a whole plan to ask one question.

A dismissed question tells the agent you did not answer and that it should not ask again. That holds only for a question you could have read (#461). At the terminal, a dialog that failed, or closed less than a second after opening (a stray key, or a terminal response landing in the first dialog after a restart), is reported as not declined: the agent may ask once more. A second such close in a row tells it the dialog may not be reaching you, and to stop asking. A Stop, a dismissal after the first second, and any headless host’s dialog read as before. The diagnostics stream (Diagnostics) records how each dialog ended and how long it was open.

Use ask when nothing useful can happen until you answer. When work can proceed on a reversible recommendation or another item can run while one is parked, the agent uses queue_question instead, which queues the question in /pending and returns at once (Questions that do not block, #929).

enter_plan_mode

The agent puts itself into plan mode. Deliberately ungated: entering NARROWS its own authority (writes deny, the tool list shrinks, delegation narrows to read-only subagents), and there is nobody to protect from an agent taking fewer powers. Plan mode’s rules are the whole process’s. A background helper already editing, even in its own worktree, has every edit denied until the session leaves plan mode. So enter_plan_mode refuses to switch while any write-capable helper (a running helper whose profile includes write, edit, or bash, or has no tool allowlist, such as general-purpose) is still running, unless called with force: true (#954). Read-only helpers (Explore, Research) do not block entry. When switching manually (/mode plan) or with force: true while helpers run, the switch warns first, naming them: "2 helpers are running (general-purpose, Explore); plan mode blocks their edits too, until you leave it" (#523). The agent that entered plan mode is told too, in the tool’s result (#648). Its helpers' prompts still name the mode they started in, so the result says to steer them (steer_subagent) or leave plan mode first if their work should go on now. Before #648 only the human saw the warning, and the agent learned of it when its helpers came back confused. Exactly ONE file becomes writable: the plan draft, announced by path on entry. It lives under the agent directory’s plans/ (beside pi’s own per-workspace session state — never /tmp, which dies with reboots mid-plan, and never your repo, which plan mode promises not to touch), is stable per workspace, overwritten by each new plan, and survives a crash — re-entering plan mode announces a surviving draft instead of starting blank. The draft’s file is named from the working directory; where a bind mount gives that directory two paths, the draft is looked for under both and the one written last is used, so plan mode entered from either path finds the same draft (#843). The other file, if there is one, is left as it is. The choice is made once for a pi process. The carve is an exact-path permission stage: a sibling file or a workspace file gets no special treatment. In any other mode the draft itself is refused, write and edit alike, with the way to author it: "the plan draft is authored in plan mode: call enter_plan_mode, then write it" (#661). Before #661 it went to the judge, which allowed a write in auto and denied an edit minutes later. Exact means the same file on the platform’s terms. Any spelling pi’s tools accept counts (~, a leading @, file://, a drive path). On Windows, case does not matter: the permission system hands the path over lowercased (#447).

exit_plan_mode

Asks you to approve the plan and leave plan mode — the one privilege escalation, so your dialog is the authorization (below).

NOTE
There is no tool to abandon plan mode. If a plan does not pan out, switch modes yourself with /mode — an agent-callable exit would restore write access with no human in the loop, which is exactly what the approval dialog exists to prevent.

Subagents get none of these three. Their asks are adjudicated by the parent’s chain, and you could not tell which child was asking.

exit_plan_mode: approving a plan

The draft file is the plan: the extension reads the file it announced at entry, so what you review is what was written — the agent cannot present a different document than it authored. Only a draft written in this plan mode counts (#659). One last written before plan mode began is an earlier plan’s. It is not presented: the plan parameter is, when given, else the exit is refused with the way on (write this plan there, or write the surviving draft again if it is this plan). Before #659 a finished plan’s draft went to a two-vendor review round while the plan the agent passed was ignored.

The shape, read before any reviewer

The mechanical half of P1 is read by code, in a millisecond, before a reviewer is called (#731): a canonical Status value, bare or bold, alone or in the header line, or under a == Status heading; an issue named (Closes: #N, Issue: #N, or filed at approval / TBD while plan mode cannot file one, #732); a Risks section (Risks, Fail modes, Rollout + risks) whose every bullet or table row names fail-open / fail-closed / silent — loud, and a bare open or closed after a delimiter, count — the first table row being its header; the tests, by category or under a Tests: label; and the delivery steps — the word CHANGELOG, a doc page, and a close near an issue. A miss is refused as plan review (deterministic policy, not a model judgement) with every miss and its line, no reviewer called, round one not spent. A plan over 1,500,000 characters is refused the same way, by its length: a review reads a plan whole, where it used to cut one at 180,000 characters (#878). It is read on every exit, so a miss edited in after round one is refused rather than shown to you. Risks written as prose, with no bullets or rows, are left to the model. Against this repository’s 73 approved plans the check passes 44; what it refuses in the rest is what the reviewers flagged for two months.

In addition, when a plan draft names an R5 deferred-execution path that auto mode refuses to edit (.githooks/, .git/hooks/, .gitmodules, core.hooksPath, ~/.pi/agent/extensions/*, or ~/.pi/agent/settings.json), the review pause appends a non-blocking Note (R5 deferred-execution) reminding the author to mark changes to those files as an explicit human step (the agent can draft replacements under .pi/scratch/ for the human to apply, #966).

The cold read before you see it

Then the draft gets a cold-review attempt — the reflection pause pointed at a plan: a reviewer chosen by the same rule, no session history, six fixed questions (#1008).

  • P1 conventions — what the shape check cannot read: nothing in the plan belongs to another issue; each change’s test category fits its risk; a risk written as prose names its mode; "verified" means observed. The reviewer is told what already passed, and not to re-litigate it.

  • P2 contextless implementability — the bar: could a fresh agent or human execute it with no further clarification?

  • P3 compatibility (release-stage aware) — automatically adapts to the repository’s detected release stage (packages/pi-workflow/release-stage.ts: checks git semver tags first, then root package.json, ignoring "0.0.0" sentinels and prereleases like v1.0.0-rc.1). Pre-1.0 repos keep the removal check (cut pre-1.0 compatibility scaffolding); post-1.0 repos (highest stable release >= 1.0.0) enforce backwards compatibility for public APIs, wire formats, config schemas, and persisted state per project guidelines (or explicit documentation and migration for an intentional major-bump breaking change).

  • P4 readable by a human — fixed once, never a blocker.

  • P5 design soundness — does the approach actually solve the stated problem cleanly and coherently, without architectural flaws, wrong abstractions, unaddressed edge cases/invariants, broken concurrency, lifecycle, clock, or budget seams, section contradictions, or reinventing existing repo primitives?

  • P6 security and failure modes — does the design preserve authn/authz boundaries, secret/PII hygiene, input validation, and fail-closed defaults on error paths (including untrusted inputs, path/symlink/TOCTOU hazards, and partial failures)?

Plan mode’s own prompt carries the plan-authoring requirements (canonical Status, Closes, fail-open/fail-closed/silent risks, tests by category, delivery steps, and the two-round P1–P6 review flow) so non-plan sessions do not carry them in global guidance (#1043). Ahead of each exit_plan_mode, it also ends with four checks on what P2 most often fails (#887). They come from reading the 22 newest P2 FAILs on this box (2026-11-09 to 11-20):

  1. Every function, type, field, constant and file the plan builds on is described as the code has it: its file, exported or private, synchronous or async, its signature, and what it does in the case the plan relies on. About twelve of the 22 failed here.

  2. Scope names every file the change touches, including the existing tests and callers it breaks (about four).

  3. Every always, never, only and cannot names the test that pins it (about four).

  4. The sections agree, and nothing is left for the implementer to choose (about four).

The plan is checked against the repository: the agent passes the files its plan names as reviewPaths, the guard verifies and inlines them (the declared-context caps apply), and P2 asks whether the named files, functions and seams exist as described. A named file the author could not supply is the reviewer’s to open (#730): it reads it, and a file that is as the plan describes it is a PASS that says so; a FAIL needs a contradiction — a name, signature, behaviour or seam the plan gets wrong, or one it needs and the tree lacks. Before #730 the rubric made an unsupplied file a FAIL even after the reviewer read it and found it right, and since a plan of substance names more files than the context caps carry, round one came back FLAGS 129 times in 131 (20 of 20 in the first week of November), which left the verdict saying nothing. Without reads (no snapshot budget) the author’s files are the only evidence and an unsupplied file is still a FAIL. A FAIL on P1, P2, P5, or P6 (and P3 post-1.0) is fixed in the plan; a pre-1.0 P3 FAIL cuts unnecessary scaffolding; anything else is an issue for the author, or is dropped.

Round two, a second vendor, reads the edited draft blind (#70, #886, #996, #1010). Round one is the author’s own model: Fable reviewing plan mode’s Fable plans. Its findings go back to the agent, which confirms and works them into the draft and calls exit_plan_mode again. Then Gemini 4 Neon reads the draft as the agent left it — completely blind to round one’s review, so a round-one PASS or partial FAIL cannot anchor its audit (planSecondReviewer in gadhs-pi-workflow.json, Configuration Cookbook). Its findings go back to the agent in turn to be confirmed and incorporated into the plan, and the call after that reaches you. It reads at high whatever the session’s level (#1010): in the 2026-12-01 P1–P6 comparison on planning-deep (10 production-scale plans), Neon at high caught 23 of 24 planted defects (18/18 unnamed) in 144 s median at $0.60/call with zero timeouts and CLEAN on both controls, outperforming Carbon at medium (21/24, 358 s, $1.19/call) and avoiding Neon `xhigh’s 333 s latency and 80 % cap hits.

So the agent makes three calls: round one, round two on its edit, then you. Each round’s instruction says which comes next. The rounds are counted per plan, not per text: round two reads the draft whether or not the agent edited it, and the call after round two reaches your dialog whether or not it edited again, with both verdicts summarized in the footer (each marked draft edited since when the text moved). The cap is deliberate: uncapped review rounds ran twenty and more for little gain, and two independent rounds, each read after the agent dealt with the one before, get the most from a bounded time. After your answer a revised plan gets a fresh round one before you see it again; there is no round three.

  • There is no round two when the second reviewer is round one’s model (a Carbon author) or none: round one’s instruction then says your dialog is next.

  • An unreachable round one gets a second try and then yields to the agent’s self-review, as for commits; round two still reads the edit after that. An interrupted or first-attempt unreachable round one spends nothing: the next call is round one again.

  • Round two’s own failure, or an escape during it, spends no attempt: the block and your pane say it did not happen, and the next call is yours.

The pane

One composed pane owns the review: a scrollable view of the document on top, then one bordered block with the scroll position (lines a–b of N, when the document overflows), the review lines, the three choices and a key legend. One component owns the keyboard, so there is no focus to juggle:

Keys Do

↑ / ↓

move the choice

enter

confirm the choice

esc

keep planning

PgUp/PgDn, j/k, home/end, ctrl+u/ctrl+d

scroll the document

e

edit the draft in pi’s editor, when the plan is a draft file (#347)

e hands the draft to pi’s editor dialog, and the pane comes back with what was saved, so a cold-review finding can be fixed without leaving the pane. A change is written to the draft file. The approval records the file as saved, the review line beside it says it is of an earlier draft, and the tool’s result tells the agent to re-read the draft before acting. A cancelled edit, or one that empties the draft, changes nothing. A plan given as the tool’s parameter has no file, so e does nothing there, and the legend names e only when it works.

In the plan viewport, a file:line whose file exists under the session’s directory is a clickable file:// link, and an #N a link to the issue, when the repository’s origin is a GitLab host or GitHub (#348, #996). These are OSC 8 hyperlinks, made only where pi-tui reports the terminal shows them (tmux included) and never in a remote session, whose files are not on this machine. A terminal without them shows the same text. Whether a click on a file:// link opens the file is the terminal’s and editor’s business, and varies.

Where pi routes the mouse (its fullscreen mode, the default), the pane takes it too (#341): the wheel scrolls the document, a click on a choice selects it, and a double-click on a choice confirms it, as enter would. A click anywhere else is pi’s. The legend adds · wheel/click only there; in regular mode the mouse does nothing in the pane.

The cold-review line reads Cold review: CLEAN — claude-fable-5-2, 41 s; or FLAGS; or UNREVIEWED — <reason> (attempt N of 2); or none recorded — adding — snapshot budget exhausted (in warning tone, even for CLEAN, #1000) when the reviewer hit its snapshot call or byte limit and — draft edited since when the draft moved after the review. Under it, when round two ran, the second-opinion line: Second opinion: FLAGS — gemini-4-carbon, 64 s, or did not happen — <reason> (<reviewer>). Each line takes its own colour, so a FLAGS second opinion under a CLEAN first stands out. The scrollable viewport holds the plan itself without appending round review transcripts beneath it (#996): confirmed fixes belong in the plan, while the footer summary lines show both verdicts. Both come from pi-workflow over the bridge (planReviewed, each record carrying its round). A new round one drops the second opinion before it, which read an earlier text. A phone or a headless host gets the same two lines. The plan is also rendered into the transcript, the durable record of what was approved.

A FLAGS review of the very draft presented says so (#913). When the draft is byte-for-byte (trimmed) the one a FLAGS round read, none of that round’s findings were applied, and a failed edit would otherwise read as an applied one: the pane’s line adds — unchanged: findings not applied (short, so it survives the pane’s width), the headless notice and the phone’s approval add (the draft is unchanged since: none of its findings were applied), and after the human decides, the author’s result begins The draft you presented is unchanged since round two’s FLAGS review: none of its findings were applied. (the later such round). Nothing is refused: the human still decides. Pins: test/plan-unapplied.test.ts, test/review-pane.test.ts and the approval-pane cases in test/wiring-lifecycle.test.ts.

The choices: Approve — implement it now; Approve — implement it, but ask me before each command; Not yet — keep planning, with optional feedback relayed to the agent verbatim. “Not yet” is a first-class outcome, not a rejection. Approval carries a duty: the draft is scratch, and a committed in-repo plan document is the implementer’s first step.

It fits whatever terminal you have

The pane is a focused overlay the TUI composites at a screen position and clamps; it never grows the transcript, and there is no minimum size. The three choices are the only mandatory region; everything else yields to them as space runs out, in this order: the document, the bottom rule, the legend, the seam, then the second-opinion line, then the cold-review line, which survives longest because a verdict bears on the decision. With no room for the document the seam reads plan above, in the transcript — true, since the plan is rendered there first. On a tall terminal the document is capped at 40 rows. Below three rows the choices cannot be shown and the tool refuses rather than drawing options you cannot read.

Only enter on an offered choice approves. esc, a dialog that throws (you are told why), a terminal too short for the choices, a session with no UI and an unrecognised answer all mean keep planning — pi’s headless UI returns undefined from a dialog, indistinguishable from escape, so anything that is not an explicit, offered approval reads as no. ask fails the other way on purpose: nothing is authorized by a question, so a dismissed one degrades to “no answer” and the agent proceeds on its own judgement, stating its assumption. Same primitive, opposite defaults.

What approval hands back

Plan mode applies its own model on entry (deep reasoning is part of the mode). Approval returns:

  • the mode you actually left, however you entered — enter_plan_mode, /mode plan, the picker or the cycle shortcut;

  • the model you were on when planning started — or the one you switched to during planning — at the thinking level it was running, since a mode’s effort is tuned for its own model;

  • the destination mode’s default, with no notice, if you entered from a mode’s own default model: only choices are restored;

  • a thinking level you chose on that default model (anything other than the mode’s declared effort, or any level in a mode that declares none, since plan applies its own on entry) is a choice too (#292). After the destination applies its defaults, the level comes back with a notice, provided the session is on the same model, since a level is tuned for its model.

  • in a session where no mode has applied a model yet (the shipped applyOnStartup: false), the model you started on counts as your choice, and when it is the destination’s own model it stays, at the level it ran before planning (#417).

The transcript’s one mode-change message names what happened ("Model is <yours> (your choice before planning, restored; the mode’s default was not applied)"). This does not need stickyModel: both decide “yours or the mode’s” by the same rule. One residual: a session resumed while already in plan mode has no record of the pre-plan model or level (the record is per session), so approval there falls back to auto and its default, announced; a model switched to during the resumed planning is still restored. Outside plan mode, exit_plan_mode is refused: there is no plan to approve, and approving a stale draft from manual used to switch the session to auto (#229). No plan review is spent on the call. On resume or reload, the mode and model are the active branch’s: a switch made on a branch left via /tree no longer wins.

Pins

  • review-pane.test.ts — a sweep from 0 to 200 rows asserting the render never exceeds its budget and shows every choice or nothing; the yield order; the tall-terminal cap; every line within width with styled, CJK and emoji content; each pager key; the review-line variants.

  • wiring-lifecycle.test.ts — the approval pane through the real wiring; a resumed session’s lost pre-plan model and kept mid-plan one.

  • wiring.test.ts — escape keeps planning: the pane resolves undefined and the tool fails closed.

Headless hosts: pi --mode rpc and whatever drives it

pi runs the same extensions under hosts other than a terminal — an IDE plugin, pi-web-ui, a supervisor’s daemon, the DHS pivot client — through pi --mode rpc, where every dialog is serialised to the host as an extension_ui_request and waits for its answer. pi says which host it is under (ctx.mode: tui, rpc, json, print), and outside the terminal the extension behaves differently in exactly these ways:

  • Every dialog is bounded, and silence is the safe answer. pi’s own dialog timeout does the bounding; an unanswered select resolves to nothing, an unanswered confirm to no. There is no timer of ours.

  • A deferred permission ask is put to the host, not to the permission system’s dialog — in a mode that keeps dialogs (pendingAsks: "dialog"). In a mode that queues, it is queued instead (Waiting on you), and the host’s own prompts are the replies. The gate’s stages run unchanged; when the outcome would have been “ask the human” — a high-consequence match, a safety-valve cap, the loop guard, a judge that could not decide, or, in a mode that runs no judge (manual), anything no rule decided (said as such, #283) — the extension asks the host to confirm, naming the tool, the command or path, the mode and why it was deferred, with unattended.gateTimeoutMs (30 s) to answer. Yes inside the wait allows. No denies, attributed to the human at the host. Silence denies, attributed to nobody: the trace says unattended BLOCKED, the reason says how long it waited and what to do (run the session interactively, or allow the pattern in the mode’s rules). The permission system receives allow or deny and never a defer from a headless session, so a host that does not forward dialogs cannot hang a turn.

  • Plan approval is a plain select. The pane needs a terminal; a host renders a select natively. The plan is already in the transcript (it is rendered before any ask), the cold review’s verdict goes ahead as a notice, then the three choices go with unattended.dialogTimeoutMs (10 min). An explicit approval approves, exactly as in the terminal. No answer is no answer: the tool says “No approval from the host within N min; you are still in plan mode” and does not ask for feedback — that prompt would wait on the same silence. An explicit “keep planning” still asks, bounded by the same wait. pi resolves a dismissed select and a timed-out one alike, so the diagnostics record (exit_plan_mode, outcome: unanswered) names the silence by the time it took (#910): dismissed when nothing came back before the wait was nearly over (within a second of it, or a tenth of a shorter wait), timed out at the wait, with waitedMs beside the configured waitMs.

  • ask carries the same dialog wait; a timeout reads as “no answer”, which it already renders.

The other cases:

  • In the terminal none of this applies — the pane, the permission system’s own dialog with its allow-always memory, no timeouts: a human is at the keyboard. (In a mode that queues, no gate dialog opens at all.) Two exceptions, both asked through pi-modes' own confirm, which shows the whole line and says why. The first is a safety-valve or high-consequence defer, which names the command that matched and the pattern (#218). The second is any defer on part of a line, where the engine escalated one command of several: the judge’s own reason is shown when it gives one (#244). The permission system’s dialog shows the line’s first command, the one its engine escalated, highlighted as the command, and says nothing of why. On cd ~/code/x && glab release … it read as a prompt for the cd, and its allow-for-session offered to approve cd *. A defer on a single command keeps that dialog, where the session memory names the command itself.

  • A host with no dialogs at all (hasUI false: pi -p, json) is not asked: ask and plan approval keep their refusals, and a deferred permission ask is denied as unattended with the host named — never booked as a human’s “no” from a host that has no human.

  • A subagent has no UI either. The permission system’s own answer to its defer would forward it to the parent session to wait ten minutes for a dialog the human is never shown, so a subagent’s defer is denied at once with the way out named: the parent can do it itself, or hand the content over in the task.

Both waits are tunable (the cookbook); 0 means deny or refuse without asking. A headless session cannot offer “allow always” (the extension returns one-shot decisions) or reach another extension’s dialog; its own dialogs reach a paired phone through the ask broker (below). The trace’s sources for these endings are host, unattended and, for a phone, remote.

A paired device: the ask broker

The pivot client (Working remotely) hands the session you are in to your phone with /remote-control. pi has no hook for one extension to answer another’s dialog, and every ask a phone must answer originates in this package — the gate defer, plan approval, the ask tool, the memory picker — so it carries an ask broker:

  • One ask goes to the local dialog and to every registered remote answerer at once, and to every answerer that registers while it is open. The first answer wins; the others are cancelled through pi’s own signal.

  • With nobody registered the local dialog still gets a live signal, so the ask stays joinable — the ten-minute headless plan approval waits for exactly this, someone picking up a phone. A phone that connects mid-ask is offered it with the same id and may win; one that registers after it settled is offered nothing.

  • One ask is outside the broker: a terminal judge or loop-guard defer opened with no phone attached is the permission system’s own dialog (the table below), decided at the defer; a phone attaching during it waits for the next defer. A valve or high-consequence defer is pi-modes' confirm, so it goes through the broker.

Three rules decide everything else:

  • A stopped turn ends the ask at once (#219). pi’s Stop, a phone’s Stop and an RPC abort all abort the turn’s signal, and the broker withdraws the open ask from every side, the local dialog and each phone’s sheet (settled cancelled), as an answer would. A gate ask then denies as stopped (the model reads "the turn was stopped before anyone answered; not run"). The ask tool returns no answer, and plan approval ends unapproved. Before this, a turn parked on an ask waited out the whole headless wait, 120 s by default, before the Stop showed.

  • The winner decides; the loser’s value is never read. pi resolves a cancelled selector to nothing and a cancelled confirm to no — values indistinguishable from a dismissal or a refusal — so an outcome is classified by who settled, never by what the cancelled side returned. A remote answer counts only if it validates: a boolean for a confirm, one of the offered options for a select, text for an input. Anything else — a malformed answer, an unknown option, a throw, a dropped link, a phone that unregisters mid-ask — is a decline, and the desk dialog keeps waiting.

  • A prompt sent from the phone is your reply to the queue (#249). pi stamps what an extension sends as extension, which never counts as yours, so pi-remote vouches for each prompt it sends: that exact text, once, within ten seconds. Nothing else vouches.

  • A phone adds an answerer, not a deadline. The wait comes from the host kind, never from the phone being there:

Host Wait Who may answer

Terminal, no phone

none

the keyboard (the permission system’s own dialog for a judge defer on a single command; pi-modes' confirm, showing the whole line and why, for a valve or high-consequence defer and for any defer on part of a line)

Terminal, phone attached

none

the keyboard or the phone; the gate defer becomes pi-modes' confirm

Headless, no phone

gateTimeoutMs / dialogTimeoutMs

the host; silence denies or refuses

Headless, phone attached

gateTimeoutMs / dialogTimeoutMs

the host or the phone; silence still denies or refuses

While a phone is attached:

  • A gate defer at the desk is pi-modes' confirm (yes / no, one shot) instead of the permission system’s prompt with its allow-always memory — one dialog on both surfaces. Plan approval keeps its pane; a phone’s approval closes it.

  • A phone’s answer is attributed to the human on the paired device: trace source remote, the deny bracket saying so, by: remote on the review log’s gadhs_host_ask.verdict, an approval announced and traced via: remote.

  • Asks the broker does not carry — the permission system’s own prompts on the excluded surfaces, third-party extensions, pi’s built-ins — are answered only at the desk; the phone shows them as a nudge, not a sheet.

The registry is process-global (globalThis[Symbol.for("gadhs.pi-modes.ask-broker")], versioned), since two extensions in one process are not guaranteed one module instance; the contract a remote implements is exported at @gadhs/pi-modes/ask-broker. pi-remote registers only while a phone is attached, and unregisters on loss.

Edit this page · latest