Workflow Modes (@gadhs/pi-modes)

A mode is a working style you switch with one keystroke: how capable the model is, how much it may do without asking you, and how carefully its actions are checked. Four modes ship — auto for normal development, plan for read-only investigation, manual when you want to approve every command yourself, and yolo when you want no checks at all.

Everything on this page is configuration, not code. If you want different models, different rules, or your own mode, see the configuration cookbook — most changes are a few lines of JSON.

The reference is split by feature:

Who decides what

The design rule behind everything here: simple checks are done by simple code, instantly. A fast, separate AI model (the "judge") is consulted only when a pattern cannot decide — and it answers exactly one question: is this action dangerous? Whether your code is good, in scope, or what was asked for is reviewed by people, not by a model watching over your shoulder.

Layer Decides Cost

Workflow guards (first, before anything else)

Commit message format, --no-verify/-n, main-branch protection, Co-Authored-By completion, SPDX headers, debt markers, GitLab identity, reflection pause

~1 ms

Mode rules

Routine commands (cd, ls, read-only git) are allowed instantly; dangerous patterns (credential files, piping downloads into a shell, --no-verify) are refused instantly. The tools that need no judgment are listed once, in the top-level allowedByRule table, and allowed by rule in every mode that has rules (#941). These are the package’s own tools (count, ask, remember, forget, yield, the plan and monitor and job tools, generate_image), pi-remote’s agent-messaging tools, pi-web-access’s web tools, and four whose effects are gated elsewhere: codemode (each call a script makes is gated on its own), get_subagent_result, steer_subagent and tool_search. A mode’s own rule for a listed tool wins: plan denies msg_post, an effect outside the plan (messaging). A tool decided by its command or path (bash, read, write, edit and the like) can’t be listed; the config check refuses it. Any other tool with no rule goes to the judge, whose rubric can’t know what it does, and a test fails for any tool the distribution registers that is in none of these places. On a bash line of several commands, a command any rule refuses refuses the line, but a rule allow counts only for a line that is one command, or for a plain line whose every command is cleared (the plainLines stage below, #888): cd x && grep -n y z | head runs with no model in auto and plan; anything else goes to the judge, whole.

~1 ms

highConsequence list

Actions you name (pushes to main, merges, publishes…) — these always stop and ask you, no model involved. Empty until you configure it.

~1 ms

Workspace-write stage

Any write/edit resolving inside the session cwd, in modes that opt in (checked after the rules and your high-consequence list)

~1 ms

Outside-write stage

Any write/edit resolving outside the session cwd and outside the temp directories, in modes that opt in (auto, outsideWrites: "deny"), refused before the judge with a reason naming compliant homes

~1 ms

Model judge

Whatever the rules could not decide, every compound bash line the plain-line stage did not clear among it: is the action itself dangerous?

~1–5 s

You

Anything the layers above passed upward. In auto and plan it waits in a queue while the agent carries on, and you answer by typing in the prompt box (Waiting on you); in manual it is a dialog

interactive

What becomes an ask

Every layer above sees only asks: tool calls @gotgenes/pi-permission-system did not settle from its own policy. Under the seeded policy (First-run bootstrap) that is almost every call: everything resolves ask except a helper’s own harness tools, and the two path surfaces are allowed, so the path rules that matter are the modes' own. Upstream releases that tighten the permission system’s path and bash gates therefore change little here; they change what a config of yours with its own path or bash rules decides. Since version 40 (from 27):

  • a path named as a for/select operand or a case subject is gated (31);

  • a redirect’s target is checked against path rules even when the file does not exist yet (34);

  • a computed argument that may spell an option withdraws `find’s, `fd’s and `sort’s claim to be only reading (36);

  • reads under ~/.pi/agent skip the outside-the-workspace gate only for pi’s own entries (agents/, extensions/, npm/, skills/ and the like), never sessions/, auth.json or the permission logs (39);

  • a bash rule written with an absolute path also matches that path’s relative spelling (40), and commands inside time ( … ) are gated on their own rules (40.1);

  • the path surfaces have read and write halves (path_read, path_write, and the same for external_directory). The seed’s bare keys stand for both; a directional key of yours outranks them, and policy-diff warns when one is left anything but allow.

Configuration resolution

  1. $GADHS_PI_MODES_CONFIG — explicit path (CI, tests)

  2. <agentDir>/gadhs-pi-modes.json — per-user overlay, merged over the package baseline (agentDir = $PI_CODING_AGENT_DIR or ~/.pi/agent)

  3. modes.json bundled with the package — the org default

Your personal overlay merges with the shipped defaults:

  • Cosmetic fields (model, effort, labels) simply override. A mode’s judge block, when you give one, replaces the mode’s whole judge.

  • Permission rules combine strictest-wins per pattern: where you name the same pattern as a shipped rule, the stricter action stands, so agency policy cannot be loosened head-on.

  • A more specific pattern of yours is kept as written, and it can carve an exception into a broader shipped deny when it refines it: the deny’s pattern matches yours, so yours names a subset of what the deny covers (/.ssh/known_hosts inside /.ssh/*, the cookbook’s recipe). Such a carve-out is named in a warning at session start. An allow that merely overlaps a deny, longer but not a subset, does not outrank it (#222).

Every block with a fixed key set refuses an unknown key by name at load: the top level, each mode, guidance, subagentPolicy, each profile under subagentPolicy.profiles, and the nested judge, title, shortcuts, unattended, compaction and monitor blocks. modelRoles accepts only the known role names, mode:<id> for a declared mode, and helper:<name> (#1040). The two maps keyed by names you choose (permission, subagentPolicy.profiles) accept any key. Keys beginning with // are comments at the top level and in a mode (not inside nested blocks).

The agency rules live inside the package, so updating it updates them; there is no copy on your disk to go stale.

Top-level config (ModesConfig)

Field Type Default Meaning

applyOnStartup

boolean

false

Apply `cycle[0]’s model/tools on a fresh session. Persisted modes are re-applied regardless. Either way the current mode’s tools are set at every session start, so a resumed session gets back a tool it lost while its extension was not loaded (#613); only the model waits for this switch.

cycleShortcut

string | null

"f2" (shipped)

Keyboard shortcut for cycling modes. (Shift+Tab is reserved by pi.)

cycle

string[]

shipped: auto, plan, manual, yolo

Order for /mode next; first entry is the logical startup mode.

announce

boolean

true

Print the active mode + shortcut hint at session start.

dropToAttach

boolean

true

A prompt naming an image file on this box sends the image with it — see Dropping a file onto the terminal. false leaves prompts untouched.

spendCapUsd

number

0 (no cap)

A session’s spend cap in US dollars (#276): pi’s own sum over the session’s entries, the footer’s cost. The judge’s calls and helpers' runs are in it already, since their cost rides on tool results. A mode’s own spendCapUsd overrides it. Past the cap, the next tool call of any kind waits on you: in a mode that queues it becomes one queue entry ("the session has spent $X, past its cap of $Y"), and /pending approve grants one more cap’s worth from what had been spent, while /pending deny stops the run. In a mode that keeps dialogs (manual, yolo) it is a confirm, the one brake yolo has; with no human to ask (pi -p), the call is refused.

bootstrapPermissions

boolean | path

true

First-run seeding of the permission-system config. false = never; a path seeds from custom JSON. Existing files are never overwritten.

safetyValve

string[]

the shipped patterns

Patterns that stay interactive in every mode that does not declare its own list (auto and plan; yolo declares an empty one) — see The safety valve.

allowedByRule

string[]

the shipped list

Tools allowed by rule in every mode that has rules (auto, plan, manual), filled into each mode’s permission at load (#941). A rule the mode writes for a listed tool stands, and an overlay’s list replaces the shipped one. The tools decided by their command or path (bash, powershell, read, write, edit, grep, find, ls, and the path and external_directory surfaces) are refused here.

guidance.global

string

unset

Operator override for the packaged global guidance digest (replaces it wholesale).

subagentPolicy

object

shipped profiles

The delegation gate’s declared tool profiles per agent — see The delegation gate: profiles maps an agent’s name to { tools }, the tools it may hold, and enforce (true) turns the gate on or off. An overlay’s profiles merge per agent: the overlay’s entry wins for an agent it names, every shipped profile it does not name stays, and its enforce wins when it sets one (#394; an overlay used to replace the whole object, so adding one agent’s profile refused every built-in helper).

monitor

object

see The monitor

The monitor’s limits: maxTimeoutMs (3 600 000; 0 is no bound), defaultTimeoutMs (300 000), maxMonitors (8), actionTimeoutMs (60 000), allowPersistent (true). Unknown keys are refused, as is a default above the cap.

stickyModel

boolean

false

Keep the model you chose when switching modes, instead of the mode’s own (tuning, "Keep your chosen model when switching modes").

recap

boolean

true

The turn recap card under a finished turn — see The turn recap (tuning).

worktreeAgents

string[]

unset

Helper types that run in a git worktree of their own (tuning).

imageModel

provider/id

"vertex-gemini/gemini-nano-banana-2.1"

`generate_image’s default model (tuning, "Generate an image").

modelRoles

object

none

Per role, a provider/id or an ordered list of them, in place of the shipped candidates (Model roles: whichever source you have, #715). Roles: mode:<id> (declared modes only), judge, judgeFallback, commitReviewer, reviewFloor, planSecondReviewer, helper:<name>, image, summarizer. Unknown role names are refused at load (#1040).

sourceOrder

string[]

none

Model sources (pi provider ids) in the order preferred for the same model, such as ["anthropic", "vertex-anthropic"] to use a Claude subscription before Vertex where both are set up (Model roles: whichever source you have, #715).

workingLine

boolean

true

The working line’s own text; false keeps pi’s (tuning).

shortcuts

object

alt+a, alt+x, alt+h

The pending queue’s approve and deny keys and the hub’s, each a key or null (tuning). Unknown keys are refused.

registryFacts

boolean

true

Check an install’s packages against their registry — see the registry check.

registryTimeoutMs

number

4000

The registry check’s one deadline for all of an install’s names.

requestWarnMb

number

20

Warn before a request is larger than this, in MiB (tuning, "Warn before a request is too big").

imageBudgetMb

number

12

Leave the oldest images out of a request whose images pass this, in MiB (tuning, "Leave old images out of a big request").

cacheRetention

"short" | "long"

"short"

The prompt-cache tier asked of Anthropic: five minutes, or the hour that writes at 2x input (tuning).

contextBudgetKiB

integer

16

The context files' size before a notice; 0 turns it off (tuning).

unattended

object

gateTimeoutMs 30 000, dialogTimeoutMs 600 000

How long an ask waits on a host with no terminal before it is refused (tuning). Unknown keys are refused.

compaction

object

fallbackModel: vertex-gemini/gemini-4-hydrogen

The model that summarises when the session’s own cannot, or null (tuning). Unknown keys are refused.

title

object

enabled, progress: true; nudge: "all"

The terminal title, its progress bar, and when it nudges (tuning). Unknown keys are refused.

modes

ModeDescriptor[]

four shipped

The modes themselves.

Per-mode config (ModeDescriptor)

Field Type Meaning

id, label

string

Stable id and UI label. Required.

model

provider/model

Main-agent model applied on switch (composed-provider path, so Vertex/ADC models work). Omit to leave the model alone.

effort

off|minimal|low|medium|high|xhigh|max

Thinking effort applied with the model.

systemPrompt

string

Written per turn as the gadhs-mode section (mode: <id> on its first line; Guidance injection). The shipped plan prompt also carries the plan-authoring conventions and review-round rules (#1043), so non-plan sessions do not pay for them.

tools

string[]

UX filter of exposed tools. Not enforcement — that is the permission system’s job. A mode without one starts a session with every registered tool pi declares by its exposure that can run on this platform. pi’s powershell comes only on Windows, since it refuses every call elsewhere (#921). pi’s tool_search comes only while a deferred tool is registered for it to find (#904). Three state-specific tools are also withheld from modes without a list (#1043): exit_plan_mode (always withheld; plan mode’s own list supplies it), yield (declared only in helper sessions carrying <active_agent>), and monitor_restore (declared only when the session’s branch holds monitors a restart ended that have not been restored). Tools reached only through codemode or tool_search stay that way. Leaving a mode with a list restores the set the session had just before it, and a switch between two modes without one leaves the tools as they are. A package’s own choice since the session started, such as pi-web-access’s web tools and their web_enable loader, stands either way.

permission

surface → pattern → allow|ask|deny

Deterministic rules, evaluated most-specific-wins (.env.example beats .env.); ties go to the more restrictive action. An allow or an ask outranks a less specific deny only when it refines it (the deny’s pattern matches its own), so git diff does not outrank /.aws/ (#222), and the ask git show : does not outrank * | sh (#923). deny is final; allow short-circuits, but only after your highConsequence list has looked, and never past the safety valve: a line the valve names goes on to the judge stage, where it is capped (#222). ask routes to the judge.

Every allow the gate gives on a rule’s or its own stages' say stands back in three cases, and the judge decides (#901, #923). The allows are a rule allow, a plain line (plainLines), the scratch root, workspaceWrites and workspaceReads; the gate asks the three checks once, before any of them:

* the action is one the safety valve names (above); * it carries a secret-shaped value in its command, path, URL or query. The values are those pi-workflow redacts from tool output: a provider’s key, a token, a JWT, a private key. So a web fetch whose URL holds a key goes to the judge, though web research is otherwise allowed by rule. This check reads pi-workflow’s redactor, and adds nothing when pi-workflow is not loaded. A write’s content never reaches the gate, so for a write it reads the path; * a file tool (read, grep, find, ls, write, edit) names a file with a credential-shaped name — either lexically or after resolving symlinks to its real location (#1023) — (the workspace stages' list): the shipped /tmp/ write allow passed .env.local in a session whose directory is under the temp root, and the /tmp/ read allow passed a read of one. The name is read as written and with the path’s . and .. segments collapsed, as the tool collapses them before it writes, so .env.local/. and .env.local/x/.. are .env.local (#935).

Three allows are not held: the delegation gate’s, since a spawn names an agent rather than an action; the plan draft’s in plan mode, one file the harness names; and your own approval of a step with /pending.

The shipped bash rules ask, so the judge decides, on git show : (a file’s content at a revision, as cat of the file would be) and git*--output* (git’s option that writes its output to a file). Without them git show*, git diff* and git log* allowed both by rule.

A bash line that is one command (redirects allowed) is matched as it stands, plus path/value for file surfaces. Any other line — several commands joined by &&, ||, ;, &, a pipe or a newline, or a line the parser reports complex (a substitution, a subshell, control flow, a syntax error) — is matched command by command and pipeline by pipeline: any deny or ask stands, naming the command it hit, and an allow is never taken from it, so the line goes to the judge, whole, unless the plain-line stage clears it (plainLines, #888).

The rules do not match a heredoc’s body (#264): a script fed on stdin that only names a protected path is not refused as if it touched it. The same path as a command’s word or a redirect’s target is matched as always, and so is any quoted string. A body can be code (bash <<'EOF', python3 - <<'PY'); what it does is then weighed by the judge, which reads the whole command, body included, or by you in manual. As with a script run from a file, which the rules never read, deliberately routing around a rule is outside what they guard against: they catch honest mistakes. Cold, with no parse to find the body, the rules match the raw text.

A heredoc does not make a line one command (#284). tree-sitter nests the rest of a heredoc’s line inside its redirect, so git status <<'EOF' && git push … read as one command and took the git status* allow; it is compound, as it reads. The rules also match the line’s heredoc header (the line with each body and terminator cut), and each line of that header on its own, so `cat <<'EOF'

sh` meets the pipe-to-shell deny whatever follows the terminator (#402: a line after it stayed attached to the header, and the deny missed).

In plan mode, a rule allow is also not taken from a line that writes a file through a redirect (git diff > changes.patch, >>, &>): plan mode changes nothing but its draft (#223). Plan’s write rule now refuses such a line before the judge is asked (#415, below). A redirect to /dev/null or to a descriptor (2>&1) writes nothing and keeps the allow. /tmp is no exception, and plan mode says so twice (#723): its prompt tells the agent to write no file beyond the draft, /tmp included, and to work through a large output by running the command again and filtering it in the pipe (`grep -E 'a

b

c'`, grep -n -C3, tail -n 400, awk for a range). The refusal of a redirect repeats it. canopy redirected a CI trace to /tmp to grep it several times, read "change nothing in the workspace" as leaving /tmp free, and learned the way that works only by asking. Only redirects are refused by rule; tee, -o <file> and mktemp reach the plan judge, so the prompt asks rather than describes.

A redirect is a write (#415). In every mode, its destination (the redirect’s first word, one pair of enclosing quotes off, a relative one read as ./…) meets the write rules and the line’s own surfaces as a path, restrict-only, as the write tool’s path does. Matched only in the line’s text, git diff > .git/hooks/pre-commit has no / before .git, and git status > ~/.bashrc 2>&1 does not end in .bashrc, so the protected-path denies missed them and git diff* allowed the write. Now a deny or ask on the destination stands over the command’s allow: /.git/ asks, and plan’s write: { "": "deny" } refuses every redirect write by rule, which is the plan judge’s own rubric without the model call. And a rule allow is not taken from a line whose redirect writes outside the session’s directory (git diff > /etc/crontab, > ../x), as the write tool to the same path is not: the judge decides in auto, and the human in manual. The temp root and the standard streams (/dev/stderr, /dev/tty) count as inside. A destination that expands ("$OUT", ~/x, a glob) cannot be placed, so it counts as outside. On Windows a destination is read as Git Bash, the shell that runs it, reads it (#535). /tmp/x is under the temp directory and /d/x is D:\x, where Node would read both as rooted on the current drive. The temp root is that temp directory by any of its names (long, 8.3 or /c/…​), never the drive’s \tmp, which is an ordinary folder. A /tmp/ rule’s root reads the same way. pi’s own write tool does not map /tmp (it writes the drive’s \tmp), so a write tool path there takes no such allow — in auto the outside-write stage refuses it, and elsewhere the judge or human decides. A write tool’s path into the temp directory itself (C:\Users\me\AppData\Local\Temp\x) meets the shipped /tmp/ rules by its /tmp spelling, and its real location must still be inside the temp directory (#541).

*A path rule reads the file, however the path is spelled (#765). The shipped path rules are written /name…, with a separator before the protected name, so a tool path given relative to the session’s directory (.git/hooks/pre-commit, the project’s .pi settings file) met none of them and was allowed as a plain workspace write; and a .. inside a protected directory hid the denied file it reached, which fell to a broader ask. Each path ask now also carries the path as it resolves against the session’s directory, . and .. folded, and a rule matches either spelling: the relative and the dotted spellings get the verdict the absolute one gets. On a remote workspace the path is the remote’s. It is lexical; a symlink is followed by the real-location stages, as before. No live ask was seen to carry a relative path - the permission system hands the absolute one - so this closes a gap in the gate’s own contract, not a route known to have been used.

*On Windows a stream suffix does not hide the file (#767). NTFS reads name::$DATA as the file name itself, and a write through that spelling changes its content; name:x is a stream hung on it. Neither text met a rule that ends at the file’s name, so a protected file inside the workspace with no broader ask over it (a submodules file, a shell start-up file) was allowed as a plain workspace write. A tool path is now read without a stream suffix on its last component, so the rules, the credential check and the real-location walk all see the file the suffix is on. A drive prefix is not a stream. Off Windows a colon is an ordinary character and the path is as typed. It holds for a read tool’s path as for a write’s: a read by a stream spelling meets the read rules as the file. A bash redirect’s destination is read the same way (#769): echo x > name::$DATA meets the write rules as name too, so the file’s own deny holds. Windows opens that spelling as the file for any program that hands it the name unchanged; Git Bash makes a separate file of that name, so there the extra spelling only restricts. A program handed the spelling as an argument (cp, tee) is the judge’s, as any write by argument is.

The write tool’s own path is held to where it really lands too (#502). A path rule matched its text, and a link changes no text: write /tmp/link/x, with link pointing at ~/.config, took the shipped /tmp/ allow. A helper’s worktree under the temp directory made a committed link a way out. Now a write or edit path rule allow stands only when the path’s real location still answers to the rule. Either the real location matches the pattern, or it lies under the pattern’s fixed root, made real itself (on macOS /tmp is /private/tmp). Otherwise auto’s outside-write stage refuses a target that lands outside the workspace and temp directories (while a dangling link stays the judge’s), and the human decides in manual: a rule matched, so the workspace stage stands aside, as it does for any matched rule. A dangling link holds nothing. In a remote session the remote’s real locations decide.

The engine asks about a line’s first command only; pi-modes reads the whole line from the ask’s evidence with the engine’s own parser. Until that parser is warm (once, at session start), every bash line reads as compound: no rule allow, the judge decides, and the deny rules, the valve and the highConsequence list match a plain text split of the line. Within a pipeline, specificity still decides — env | grep -c neutralises the broader env | grep* deny.

workspaceWrites

"allow" | "ask"

"allow": writes/edits whose real location is inside the session cwd are allowed deterministically, after deny/ask rules and highConsequence have had their chance. Real, not lexical: a symlink inside the tree pointing out is followed by a write, so a path through one is outside (refused deterministically in auto by outsideWrites, judged elsewhere), while a dangling link stays the judge’s; a file that does not exist yet lives where its deepest existing parent really is. A credential-shaped basename (the read stage’s list: .env*, key and certificate extensions, SSH key names, credential, secret, .netrc/.npmrc/.pypirc) is not covered: the judge decides it in auto, and the human in manual (#414). Nor is a write the safety valve names or one carrying a secret-shaped value (see permission). Shipped on in auto and manual; omitted in plan (read-only by contract).

outsideWrites

"deny" | "ask"

"deny": write and edit asks whose real location is outside the session’s workspace and outside the temp directories are refused deterministically by the gate before the judge, traced and recorded as outside-write (#943). Temp homes the row stands back for: the host’s temp directory (tmpdir(), and /tmp off Windows), plus /var/tmp, /var/folders, /run/user and an absolute $XDG_RUNTIME_DIR on POSIX (and /tmp, /var/tmp, /var/folders, /run/user on a remote host). Stands back whenever a matched path allow rule holds on the real location (such as a credential-shaped name held for the judge by heldForJudge), when the path is inside the workspace, or when the real location cannot be resolved (missing cwd, dangling link, ~ on a remote, lost link). The refusal names the compliant homes: inside the workspace, a git-excluded worktree at .worktrees/<name> listed in .git/info/exclude, worktreeAgents in the human’s modes overlay, .pi/scratch/, or a temp directory (and tells a forwarded helper to report to its parent rather than retry). Four ways to let an outside path through: add a path allow rule in your modes overlay, add a highConsequence pattern to prompt interactively, set "outsideWrites": "ask" in your overlay to restore the judge, or switch to manual. Shipped on in auto only (plan denies all writes by rule; manual asks the human; yolo allows all).

workspaceReads

"allow" | "ask"

"allow": read, grep, find and ls asks whose path resolves inside the session cwd are allowed deterministically, after deny/ask rules and highConsequence. Shipped on in auto, plan and manual.

Left to the judge: a credential-shaped basename (.env*, key and certificate extensions, SSH key names, credential, secret, .netrc/.npmrc/.pypirc); a read the safety valve names or one carrying a secret-shaped value (see permission); a path whose real location, through every symlink, is outside the tree; a path that does not exist; a read with no path. A grep, find or ls with no path is asked about the cwd; grep and find respect .gitignore.

Both stages read a path the way pi’s tools do before judging it. A ~, a leading @, a file:// URL and a Git Bash or WSL drive path each name the file pi will open, resolved against the session’s directory, so ~/x is the home directory’s file, never an in-tree directory named ~ (#447).

In a remote session (pi over SSH, #498) the session’s directory is a local anchor holding none of the project. Both stages, and the rule for a redirect’s destination, then ask the remote where a path really lands, following symlinks where they are. A relative path, or one under the anchor, is read as the remote path it stands for before any rule sees it. So .pi/settings.json meets the rule for a project’s .pi/settings.json, not the rule protecting pi’s own directory, where the anchor lives. A ~ path names the remote’s home, which pi cannot resolve from here, so the judge decides it. A lost link decides nothing either way, so the judge answers then too.

On a Windows client the permission system hands the gate its own canonical path: resolved against the local drive and lower-cased. That spelling names nothing on a case-sensitive remote (/home/me/app/x arrives as c:\home\me\app\x, Cargo.toml as cargo.toml), so in a remote session the gate reads the path the file tool was called with instead (#997). pi-modes records each read, write, edit, grep, find and ls call’s path by tool call before the permission system asks about it, and uses it only when it spells, on Windows terms, the path the permission system gave. An ask with no such record (a call this session did not see) is unplaced: no rule or stage allows it and the outside-write stage does not refuse it, so the judge answers. A deny rule still refuses on the name. test/tool-call-paths.test.ts pins the record and the check, test/judge-wiring-callback.test.ts the verdicts.

A helper’s asks are forwarded to the parent session and decided there, so this stage answers a helper’s in-tree reads; a headless parent serves nothing, and a forwarded ask there is a blocked tool call. Any tool-input preview the permission payload carries (input evidence) is recovered into toolInputPreview so the judge (input-preview), the secret-shape check, the delegation gate and non-bash shell units see the helper’s input just as on a local ask (#947). An ask whose path is absolute is placed by the workspace that path is in (#492). So a remote helper’s write in its own worktree is contained against that worktree, not against the parent’s root.

plainLines

"allow" | "ask"

"allow": a plain bash line is allowed deterministically when every command of it is cleared (#888), after deny/ask rules, highConsequence and the safety valve; traced as plain-line. Shipped on in auto and plan; manual and yolo do not set it.

A line is plain when it holds only commands joined by &&, ||, ;, a pipe or a newline, with literal words: no substitution, variable, subshell, brace group, control flow, heredoc, here-string, input redirect, background &, negation, [ ] test or assignment. Its only redirects are a descriptor duplication (2>&1) or a write to /dev/null, so it writes no file through the shell.

A command is cleared one of two ways. A command outside the roster below is cleared only when this mode’s rules allow its text, as they would allow it alone: so a standing approval’s command now also runs behind a cd. A roster command is decided by its own proof alone, and a rule allowing its text does not rescue a failed proof. The roster, 23 commands:

* cd, with one operand, entering a directory inside the session’s directory or the temp root; never in a pipeline. * pwd, true, false, :, echo, printf, tr, with any words; exit and sleep with a number; test, every file it asks about readable (below). * cat, head, tail, wc, cut, sort, ls, each with only the options that read and print, and only readable files. * uniq with no file at all, since its second operand is written. * sed only as sed -n with print commands (sed -n '10,20p'). * grep, egrep, fgrep, with readable files; a recursive search (-r, -R) only when it prints no file content (-l, -L, -c, -q).

A file is readable when, followed through every symlink, it is inside the session’s directory or the temp root, and its name is not credential-shaped (the workspace stages' list), from every directory a cd earlier on the line may have left the shell in. Options are read as the program reads them, quoted or not: sed -n 1p -i a.ts and sort '-o' out a are refused, as GNU tools take an option anywhere. A brace in any unquoted word, a glob in one (except after a long option’s =), a ~ after an =, and a leading ~ other than ~ or ~/… are refused, since the shell would expand them.

Left to the judge: a line any rule matched, a helper’s ask, a remote session’s, a line the safety valve names, one carrying a secret-shaped value in its text or its preview (#923, #901), and every line that is not plain or has a command not cleared. node tools/task.mjs plain-line-field <sessions dir> replays session files through the gate offline and counts what this stage allows and why it stood back.

highConsequence

string[]

Patterns that always wait for you (queued, or a dialog; see pendingAsks), before any model gets an opinion and before any rule allow takes effect — for the actions that commit your team to something (a push to main, a package publish, a production deploy). Empty by default: every team’s list is different, so the package does not guess yours. See the cookbook.

pendingAsks

"queue" | "dialog"

What happens to an ask the gate cannot settle alone: a judge defer or failure, a safety-valve cap, a high-consequence match, the loop guard. "queue": it waits for your typed reply while the session goes on (Waiting on you). "dialog", the default, so an overlay changes nothing it did not ask for: a dialog the session waits on. The shipped auto and plan set "queue" (#249).

canSpawn

string[]

Subagents this mode may delegate to, by name, or "" for any agent with a declared profile (#400). Omitted/empty = no delegation. Auto, manual and yolo ship [""]; plan names its read-only helpers.

judge

JudgePolicy

The model judge for ask decisions — see The judge. Omit it (manual mode does) and every ask goes to the human.

spendCapUsd

number

This mode’s spend cap in US dollars, over the top-level spendCapUsd; 0 is no cap.

planAuthoring

boolean

This mode authors a plan draft: the one file it may write or edit, the per-cwd draft under the agent dir’s plans/. The carve runs before the mode’s own deny rules, and every other write stays as the rules say; outside such a mode the draft is refused (#38, #661). A line that writes takes no rule allow in such a mode. Plan ships true.

The shipped modes

Mode Model / effort Rules Workspace writes Judge Character

auto

Opus 5.5 / medium

yes

allow

Sonnet 5.5 low, advise

Implement end-to-end. Rules absorb the routine; the judge sees only the ambiguous; writes in-repo are free; writes outside the repo and temp are refused deterministically (outsideWrites).

plan

Fable 5.2 / xhigh

yes

—

Sonnet 5.5 low, advise, plan rubric

Investigate and design, change nothing. write and edit stay in the tool list but are denied by rule (*), except the plan draft itself; bash is judged against the mode contract.

manual

Opus 5.5 / medium

yes

allow

none

The human approves every ask personally. Same rules as auto, no model in the loop.

yolo

Opus 5.5 / medium

no

—

allow-all (no model)

Auto-approve everything. yolo means yolo: no rules and no judge model — only yolo’s own valve list (empty unless you add to it) and pi’s structural gates remain. The workflow guards still run.

Switch with /mode (a picker), /mode <id>, /mode next, or just press F2. The status line always shows the active mode and what it is doing (what waits on you, what the gate did, the helpers working, the monitors running, the jobs watched, the agent messages collected and not yet read, the spend; each segment only while it has something to say); when something is blocked, a line appears in the transcript saying who blocked it (a fixed policy, the judge, or a workflow check) and why — expand it for the full reasoning and what to do about it. /gadhs-reset lists every local tuning file in force and, with --apply, moves them aside so the package defaults apply again (tuning).

Model roles: whichever source you have

Every model the distribution names fills a role (#715): each mode’s model, the judge and its fallback, the commit reviewer, the reviewer floor, the plan’s second reviewer, the helpers, the image tool and the summarizer. Each role has ordered candidates, resolved at each session start against the models pi can reach for you (those whose provider has a key or login):

  1. the role’s own configured model first: a mode’s model, pi-workflow’s reviewer, a helper’s agent file;

  2. then the same model through each source: Vertex, then pi’s own anthropic login (an API key or a Claude subscription) or google (AI Studio), which carry the same model ids, so the battery’s evidence holds;

  3. then the other vendor’s nearest tier, a substitute: Explore on Claude Haiku when no Gemini is reachable, say. Substitutes are unmeasured until the battery runs them.

A Vertex box resolves exactly as before, since every role’s first candidate is the model it named. When any role resolved to something else, the session starts with one line saying what and through which source: models: judge: claude-sonnet-5-5 via anthropic; summarizer: claude-haiku-5-5 via anthropic (substitute, unmeasured). /mode models lists every role at any time.

With nothing reachable, a role does what it did before. A mode keeps the current model, said once a session. The judge defers every ask to you. The image tool refuses a call that names no model, saying what it tried. The summarizer leaves compaction to pi. The image role has Vertex candidates only: pi’s google provider has no image model under that id.

The helpers resolve in pi-agents (#715). Each managed agent file is re-rendered at session start to the model this user reaches, its override from gadhs-pi-agents.json or its packaged model first. The answer is kept in gadhs-pi-agents.resolved.json and rendered at the next load, so an unchanged box writes nothing. A substitute is named at start: "agency agents: Explore runs on anthropic/claude-haiku-5-5, a substitute (unmeasured): … is not reachable". A file you own is never written, and with nothing reachable the file keeps its packaged model and the existing warning says where pi-subagents will run it. pi-modes reads the agent files again after a re-render, so the model lock and the helpers' pricing see the model pi-subagents will run.

modelRoles replaces a role’s list outright, in its own order. sourceOrder reorders the same-model tier by provider. It never lifts a substitute above the role’s own model.

Scratch root

<repo>/.pi/scratch/ is the one place the working agreements name for a file that is not part of the tree but must outlive the turn: a commit message for git commit -F, a helper’s brief, a draft, a list to come back to (#738). It is inside the checkout, so it sits on the repository’s own filesystem - not a root filesystem the box’s notes rule out, not a /tmp a reboot clears - the commit guard reads a -F file there as it reads any file in the workspace, and a reviewer can be pointed at it with Review-Context. It is text; a build never lands in it, and nothing measures or prunes it for you.

At session start pi-modes writes one anchored line, /.pi/scratch/, into the repository’s .git/info/exclude - git reads it as a .gitignore it never commits - once, under a comment, and says so that session. A worktree’s session writes the common repository’s file, so every worktree shares the line; where git already ignores the root - an exclude, a .gitignore, the global excludes, asked with git check-ignore - nothing is written; outside a repository nothing happens; a failure is logged and never fails the session. A remote session writes the remote checkout’s file through the same seam. Nothing is created under the root until something writes there, and the directory is the agent’s to make (mkdir -p; the write tool makes it on the way).

A write there is allowed by rule (#747). The shipped policy holds a project’s .pi as an ask on the write and edit tools, because pi loads settings, agents and extensions from it; that sent every scratch write to the judge, which answered both ways for one directory. pi loads nothing from the scratch root, so in a mode whose workspace writes are allowed (auto, manual) a write or edit that lands under the session directory’s .pi/scratch/ is allowed with no model call, traced as scratch-root. It is decided on where the write really lands, not on the path’s text: .pi/scratch/../settings.json, a link in scratch that points elsewhere, a .pi/scratch/ nested in some other directory or under the home, and the root itself are not it — in-workspace misses are judged as before, while targets landing outside the workspace and temp are refused in auto (outsideWrites). A deny rule is never overridden, a credential-shaped name, a path the safety valve names and one carrying a secret-shaped value stay the judge’s, and plan mode allows no write here as anywhere. The judge’s rubric names the exception too, for a bash redirect into the root.

What is not in scratch: builds, which go to the repository’s gitignored build directory where every tree shares one cache, and helper worktrees, which stay in the temp directory and opt-in (A helper in its own git worktree). The default is the primary checkout, one unit at a time, on branches.

First-run bootstrap

On first load the extension seeds a minimal permission-system config (only when absent — never overwriting, even an invalid one):

{
  "permissionReviewLog": true,
  "authorizerChain": ["gadhs-mode-judge"],
  "permission": {
    "*": "ask",
    "yield": { "*": "allow" },
    "ask_parent": { "*": "allow" },
    "notify_parent": { "*": "allow" },
    "path": { "*": "allow" },
    "external_directory": { "*": "allow" }
  }
}

yield, ask_parent and notify_parent are a helper’s own harness tools, settled in the child before anything is forwarded. yield is its result submission: it validates the child’s result, writes it beside the child’s transcript and ends the run. ask_parent records a question for the agent that delegated and ends the helper’s turn; notify_parent sends that agent a one-way update. pi-subagents gives both to every helper, whatever its tools list says. None of the three reaches anything the child could not already reach. Left at ask, each call would be forwarded to the parent session: a judge call every time, and a refusal under a headless parent, so a helper could not hand in its result or ask its question.

This file is deliberately tiny: it just routes every permission question to the mode system, which is where all the real policy lives (and updates with the package): agency rules ship in modes.json and are enforced by the extension’s authorizer, precisely so that policy reaches every developer on update — anything written to disk is seeded once and never migrates. The seeded file must also stay strictly schema-valid: a // comment key silently clamps the entire permission config, chain included. If you have edited yours and want to know how it differs from the current default, node tools/task.mjs policy-diff will tell you, and --write will repair it (it asks first, adds what a later seed added, and raises what you left looser; it never removes or relaxes a rule of yours). A config seeded before ask_parent and notify_parent were added needs --write to get them.

The same load seeds one key of pi’s own settings (#726): cacheWarming: "idle" in ~/.pi/agent/settings.json, when no value is there. Up to pi 1.5.0 pi warms a prompt cache between runs only when told to (1.5.1 does by default), and the between-run pauses were two thirds of a week’s spend on one session. The key is added under the lock pi takes on that file, so a save pi makes at the same moment loses nothing; a value you set is never touched; the session says what it wrote, once, and the value applies from the next start or /reload (tuning).

Edit this page · latest