Agents and LLMsHarness and toolingreference
Subagents, worktrees, and parallel agent work
The pi harness runs parallel work through four worker kinds (task, bg_task, bg_bash, bg_loop) plus /btw side questions. They share one lifecycle: progress streams into a panel under the editor and no worker runs mutating git. task workers also resume after transient provider errors. File-level /undo is covered at the end of the page.
The loop agents spawned through this surface are covered in Loop or graph: a sensor-gated coding-agent loop. The gates that block workers from running git are covered in The guard extensions that police agent tool calls.
Every mechanism below is read from the harness source. Incidents come from session history and carry their dates.
TL;DR:
- In an interactive session
taskreturns at once by default and its result arrives later as a message that wakes the parent;wait: trueorPI_TASK_BACKGROUND=0blocks instead, and a headless parent always blocks.bg_task,bg_bashandbg_loopreturn a handle at once and push a completion nudge later. - Before any implementation work the session picks a mode from the shape of the work: direct,
task, one loop, one foreman wave or a loop graph. A mode the user names is checked against that shape, not obeyed, and the first inline code edit on work shaped for a wave is blocked once per prompt. - Since pi 1.8.0, each finished
task,bg_taskand/btwworker writes its token usage and cost into the parent session, nested workers included, so the session’s cost total covers its workers. - At most 4
taskworkers run at once (PI_TASK_MAX_PARALLEL, default 4); extra calls queue.bg_taskpi workers have a separate pool per session tree (PI_BG_MAX_PARALLEL, default 4) that refuses extra spawns instead of queueing, andllmc/workers are exempt from it. A 402 on OpenRouter’s in-flight credit budget killed one of six workers on 2026-10-19, and the cap shipped on 2026-10-20. - A
taskworker hit by a transient provider error is resumed up to 2 times, after a 30 s, 60 s or Retry-After backoff capped at 180 s, plus up to 50 % jitter so workers given the same Retry-After do not resume together (added 2026-11-05 after four expensive-model workers failed both resumes in lockstep). - A repo with large submodules can run several workers in its main tree instead of worktrees, if each has an explicit file list and none runs a tree-wide regenerator.
- Workers never run mutating git (2026-10-20). They edit files in a worktree the main session created, and the main session commits, merges and pushes.
/btwforks the session into a read-only worker that answers while the main turn keeps running./undorestores the files the agent changed together with the conversation.
Topology
Section titled “Topology”Choosing the execution mode
Section titled “Choosing the execution mode”The worker kinds below answer how to run delegated work. The harness also has to decide whether to delegate at all. Until 2026-12-03 its rules routed read-only work to task, long delegated work to bg_task, and several cards at once to foreman, but each rule fired only once the session had already framed the work that way, and none told it to sort implementation work by shape before starting. The count of foreman wave state directories last modified per day went from 21 to 42 a day (2026-11-22 to 11-28) to 1 to 8 (11-29 to 12-01) and none on 12-02 and 12-03. That counts directories by modification date, not waves started, so it shows a trend and no more; the session titles from those days show card reviews and feature work run in the main session.
The rules now open the background-work section with a first-match list, and the session names its pick in one line before the first edit:
- Work that needs this conversation’s context, attached hardware, a person in the loop, a judgement call with no pass/fail check, or only a few minutes of edits: direct, in the session.
- Read-only exploration, research angles and review passes:
task. - Two or more cards or changes with an objective gate (build and tests, lint, a failing repro test), independent or stacked: one foreman wave. Not parallel loops, a hand-built graph of card worktrees, or the cards one at a time in the session.
- Exactly one such card or change that will take several edit-and-test rounds:
bg_loopin a worktree. - An ordered pipeline of loops and shell steps that is not a set of cards:
bg_loop graph=.
A first version listed the one-card loop rule before the wave rule. Asked how it would work two gated cards and one judgement card, a headless session applied “first match” card by card and picked two parallel loops. With the wave rule first, the same question gave one wave plus direct work, and a one-line fix with a failing test stayed direct.
A request to work the board, do a list of cards, or review cards and resume sorts the cards by the list first: gated cards go to a loop or a wave, the rest stay direct.
Modes the user names
Section titled “Modes the user names”A user who types “use foreman” or “run it in a loop” has named a mode, not checked it against the work. The rules treat the named mode as a proposal: when the shape does not fit, the session says why in one line, recommends the mode that fits, and uses the named one only if the user confirms after hearing the reason.
The work-router extension enforces this. On each prompt the user types into the main session (20 characters or more, not a slash command), it reads card references (project#123), implementation and judgement verbs, hardware words (flash, scope capture, attached) and any named mode, and turns them into a route. It injects the route as a reminder at the end of the context, at a fixed position, so the prompt cache prefix is not disturbed (work-router.ts over lib/reminder-core.ts; the classifier and texts are lib/work-router-core.ts). When a named mode does not fit, the reminder says why:
| Named mode | Shape | Reason the reminder gives |
|---|---|---|
| foreman | one card or none | a wave runs two or more gated cards |
| loop, foreman or graph | hardware words | loops run unattended in worktrees and cannot reach attached hardware |
| loop, foreman or graph | a judgement or research verb (decide, compare, why, review) and no build or fix verb | there is no pass/fail check to loop on |
| loop or graph | two or more cards | one foreman wave runs, judges and lands them |
| subagents | two or more cards to fix | task workers cannot commit or land and have no objective gate |
| direct | two or more cards to fix | one at a time in the session loses the parallel run and the judge |
On a prompt shaped for a wave (two or more cards with implementation work) or for sorting the board, the first code edit after that prompt is blocked once with the route. Only the file tools count (a write through bash is not seen), and edits to Markdown and text files, docs/, /tmp and local state paths are exempt. Each new routed prompt is a new task and re-arms the block. The session either starts the wave or states its pick and reason and retries, and the retry passes. foreman plan, foreman start or any bg_loop call disarms the block. Workers and loop agents get a brief rather than the user’s words, so the extension skips them; PI_WORK_ROUTER_OFF=1 turns it off.
The classifier is a set of regular expressions, so it misses phrasings it does not know. The session still makes the call; the extension makes it state the call before editing. Two headless probes on a throwaway repo, run 2026-12-03:
- “Use foreman to fix” one card: the session answered that it was one card, not a wave, fixed it directly and did not run foreman.
- Two one-line fixes on two cards: the first edit was blocked; the session replied that two one-character fixes fit direct work, retried, and the tests passed.
Which worker for which job
Section titled “Which worker for which job”| You need | Use | Mechanism |
|---|---|---|
| A sub-task whose result the parent reads before continuing | task | Runs in the background in an interactive session; the result arrives as a message (wait: true returns it in the same turn). Several task calls in one message run in parallel. |
| Research, audit or a deep refactor that should not block you | bg_task | Detached pi -p in tmux. Returns a handle and pushes a completion nudge. |
| A polling loop, slow download or long build, past the 30 s bash-tool timeout | bg_bash | Detached shell in tmux, no pi process. |
| An unattended build/lint/test loop with a model ladder | bg_loop | loop run with per-iteration progress in the agent view. loop graph run for multi-node graphs. |
| A quick lookup that must not interrupt the running turn | /btw | Read-only fork of the session. The answer lands in the transcript as a collapsed entry. |
| A read-only deep dive that must finish before continuing | task with explore | No full extension load, so it starts cheaper. |
| Two or more independent research angles | several task calls in one turn | Parallel dispatch. Each worker writes its results and the parent synthesises. |
The worker kinds
Section titled “The worker kinds”task: inline subagent
Section titled “task: inline subagent”task spawns a fresh pi -p process, feeds it the prompt, parses its JSON (JavaScript Object Notation) event stream for progress, and returns the final assistant text. In an interactive session the call returns at once and the text arrives later as a task-done message that wakes the parent if it is idle; wait: true, or a headless parent, blocks until the worker exits (task.ts). Workers are one-shot: there is no multi-turn conversation with a task subagent.
task.ts defines two presets, plus general-purpose as an alias for general:
| Preset | Tools | Extensions |
|---|---|---|
explore | read, grep, glob, docs_search, docs_read, docs_grep, docs_find, docs_summary, docs_sources. No bash, no writes, no web search. | --no-extensions --no-skills --no-prompt-templates, then docs.ts, glob.ts, worker-inbox.ts and lineage.ts loaded back in |
general | All tools; the model argument, else pi’s configured default model | All |
Parallel dispatch: each task call in one turn becomes a separate subprocess. A counting semaphore caps concurrent workers at PI_TASK_MAX_PARALLEL (default 4) and queues the rest until a slot frees (task-limits-core.ts).
Incident, 2026-10-12: three parallel workers on openrouter/~deepseek/deepseek-flash-latest printed DSML (DeepSeek Markup Language) tool-call markup as text and ran zero tools. tool-routing.md now names that model as unfit for workers and says to check a worker’s tool count in bg_status before trusting its silence.
bg_task: detached pi worker
Section titled “bg_task: detached pi worker”bg_task is the same pi -p subprocess inside a detached tmux session. The tool returns the session handle within about 100 ms. When the worker finishes, the tmux wrapper updates a state file and a completion watcher pushes the result to the parent as a steer. State lives at ~/.pi/agent/bg-tasks/<name>.json. Workers inherit the parent’s extensions and skills unless minimal: true is set. The model is the model argument, else PI_BG_DEFAULT_MODEL on non-minimal runs, else pi’s configured default (bg-tasks.ts).
A worker on the local llmc stack gets a 20-tool allowlist (LLMC_DEFAULT_TOOLS) and no MCP (Model Context Protocol) servers, so the single-lane engine’s prompt-cache prefill stays small. With every MCP server loaded, the first request carried about 77.5k prompt tokens before the first tool ran (bg-tasks.ts).
Every bg_task prompt is prefixed with HEADLESS_WORKER_PREAMBLE: nobody reads the worker’s messages until it finishes, git is blocked, the question tool has no UI (user interface), and it must finish or stop with a precise blocker.
bg_bash: detached shell command
Section titled “bg_bash: detached shell command”bg_bash runs a bash command in a detached tmux session with the same lifecycle as bg_task and no pi process. The command text is written to a tempfile and run as bash <tempfile>. Output streams to the tmux pane and to ~/.pi/agent/bg-tasks/<name>.log, which outlives the 30 s tmux grace period after exit (bg-tasks.ts).
bg_loop: self-correcting loop in the background
Section titled “bg_loop: self-correcting loop in the background”bg_loop runs loop run --events <file> inside tmux. The JSON event stream (run_start, sensor, iteration_start, iteration, run_end) drives an agent view row with iteration count, model, phase and failing sensors, and the completion nudge carries the result instead of a raw log tail. bg_loop graph=<graph.json> runs loop graph run, which orders loop manifests and shell cmd nodes as a dependency graph, with no approval prompts and the governor owning git. The mechanism is in the self-correcting loop reference.
Worker cost in the parent session
Section titled “Worker cost in the parent session”pi 1.8.0 added pi.appendUsage(): an extension can write a usage entry into the session file, and pi’s footer cost, session stats and /session count it. It never enters the model’s context. Before it, worker spend lived only in an in-memory ledger that the spend warnings read: the footer left it out, and the figure was gone after /reload or a resume.
Now each finished worker records one subagent usage entry per model it used, summed from the assistant messages in its event stream (lib/worker-usage-core.ts):
task, when the run ends.bg_taskpi workers, from the completion watcher of the session that owns them. An atomic marker file next to the worker’s state file makes it record each worker at most once, also whenbg_waitreported the result or the session was resumed./btwforks, which now also count in the spend ledger.
A worker that delegates writes its own workers’ usage into its own session file, and those entries never appear in its event stream. When a worker finishes, the parent reads the usage entries written to the worker’s session file since the run started and records them too, marked as nested, so the count covers any depth. A resumed task does not report its earlier runs again. The spend warnings add worker cost through the in-memory ledger that task and the watcher feed, and never read the usage entries, so nothing is counted twice.
A session keeps the extension code it loaded at start, so a change like this one reached running sessions only on /reload or a restart. The code-reload extension now watches the extension and prompt files: an interactive session shows code changed: /reload in its status line, and an unattended one reloads by itself once it is idle, no task or /btw worker is running (a reload kills them), no finished result is waiting for delivery, the model is not the local engine (a reload would refill its whole cache) and the changed files are committed. bg_task workers run in tmux and survive a reload. In a tmux session on 2026-12-04 the notice appeared after an extension file changed, the unattended session reloaded on its own, and /reload also loaded an extension file created after the session started.
Verified on 2026-12-03 with headless runs: a task run and a bg_task worker each left one usage entry with model and cost in the parent’s session file, and a worker that called task left its leaf’s cost there as a nested entry. That pi’s footer then shows the total rests on pi’s documentation, not on a check.
Lifecycle and the agent view
Section titled “Lifecycle and the agent view”Every worker kind registers with a process-wide registry (lib/agent-view-core.ts). The agent-view extension renders it as a list under the editor, a port of Claude Code’s agent list (plan docs/plans/2026-10-12-pi-agent-view.md).
Keys, with the editor empty:
| Key | Action |
|---|---|
| Down arrow | Enter the list |
| Up / down | Move between rows |
| Enter, or a click | Open the live transcript overlay |
x | Stop the worker |
| Esc, or left arrow | Leave the list |
Finished rows stay for 30 s (LINGER_MS) and then drop. Each row shows a status glyph, elapsed time, turns, tool count and the last tool label.
Streaming: task and bg_task both emit pi --mode json event streams. lib/bg-stream.ts extracts tool calls, assistant text, token counts and errors into a transcript.
Completion nudge: when a bg_task, bg_bash or bg_loop finishes, the watcher pushes the final output into the parent session as a steer. It is keyed on the parent’s session id, so it survives --session resume, and PI_BG_NOTIFY=0 disables it. A running bg_wait returns early when another task finishes, so the steer is not held behind it. bg_wait itself blocks until a pattern matches a worker’s output, the worker exits or a timeout elapses, replacing a chain of bg_status calls across turns.
Steering a running worker
Section titled “Steering a running worker”The agent view overlay has an input line. A message typed there reaches the viewed worker as a steer:
- The parent (
task.tsorbg-tasks.ts) appends a JSON line to a per-worker inbox file named byPI_WORKER_INBOX(lib/worker-inbox-core.ts). worker-inbox.tsinside the worker polls the file every 300 ms, records each message withpi.appendEntry(the parent’s transcript shows> typed message), and delivers it withpi.sendUserMessage(..., {deliverAs: "steer"}).- The model sees the steer after its current tool calls finish.
Nothing reaches a worker after it settles. A row whose provider canSend is false (finished, or spawned without an inbox) shows a read-only line instead of the input.
Provider errors and the concurrency cap
Section titled “Provider errors and the concurrency cap”The 402 incident (2026-10-19)
Section titled “The 402 incident (2026-10-19)”Six parallel deepseek workers were dispatched in one turn. OpenRouter returned a 402 on one of them with the reason in_flight_budget_exhausted. OpenRouter reserves credit per in-flight request, so six concurrent requests consumed the reservation. The worker died and its work was lost (header of task-limits-core.ts).
The fix: semaphore and retry
Section titled “The fix: semaphore and retry”task-limits-core.ts (2026-10-20) adds two mechanisms.
Concurrency cap: a FIFO (first in, first out) counting semaphore gated on PI_TASK_MAX_PARALLEL. maxParallel reads the variable and falls back to 4 when it is unset or not a number.
Transient-error resume: when a worker’s last request fails with a retryable provider error, the spawner waits and relaunches the worker from its persisted session with the prompt “Continue the task from where you left off.” Up to MAX_RESUMES (2) retries.
| Error | Retried |
|---|---|
| 402 with in-flight wording, 429, 5xx, overload, dropped connection, timeout | Yes |
| 401, 403, 400 | No, fails at once |
| 402 without in-flight wording (out of credits) | No, fails at once |
Backoff is the Retry-After value when the message has one, otherwise 30 s then 60 s, clamped between 5 s and 180 s, plus up to 50 % random jitter (never earlier than the provider asked).
The second 402 (2026-11-05): an expensive model and lockstep resumes
Section titled “The second 402 (2026-11-05): an expensive model and lockstep resumes”The cap of 4 assumes a cheap model. OpenRouter reserves credit for each in-flight request’s whole max_tokens at the model’s output price (max-tokens-cap.ts header, 131072 tokens by default), so the same budget fits fewer requests on a pricier model. Four openai/gpt-5.5 fact-checkers each ran about 6 minutes (49 to 61 tool calls) and then all got 402 in_flight_budget_exhausted with Retry-After: 120. All four waited exactly 120 s, resumed together, filled the budget again and failed; the second resume failed the same way. Each worker’s session log shows three prompts and three errors. The fifth worker, queued behind the cap, started later and finished with two errors.
Two changes followed: the jitter above, so workers given the same Retry-After spread out, and a routing rule to run wide fan-outs of expensive models on anthropic/ models or two at a time. The rerun on Anthropic models finished all four checks.
Error surfacing in the stream
Section titled “Error surfacing in the stream”Before that fix, a provider failure arrived as an assistant message with empty content and stopReason: "error". extractAssistantText dropped it, so the failure left no trace. lib/bg-stream.ts now runs noteOutcome on every assistant message, stores the errorMessage as lastError and pushes an [error] transcript entry. If no assistant text ever arrived, the result is "[subagent produced no output]", and the caller reads lastError for the reason.
Worktree isolation
Section titled “Worktree isolation”Two agents in one working directory share one index, one working tree and one set of untracked files. A worktree gives each its own index and tree, and shares the object store and refs with the main tree, so a merge needs no fetch (git-worktrees skill, tool-routing.md).
The hazard
Section titled “The hazard”| Mechanism | Effect on the other session |
|---|---|
Checkpoint git add -A | Stages the other session’s in-progress files. If the human then commits, unrelated work rides along. |
| Scope revert | Deletes an untracked file outside writeScope, so the other session’s new file is gone. |
| Rollback to checkpoint | Restores files from the checkpoint index. Files created after the checkpoint were never in it. |
An untracked file deleted by a scope revert was never committed, so git fsck --unreachable finds no blob. The only copy was in the authoring session’s context.
The flow
Section titled “The flow”Setup, by the main session:
git worktree add .worktrees/<card>-<slug> -b agent/<card>-<slug> mainin the repo root. This is routine git and runs without a prompt.- Symlink
node_modulesinstead of reinstalling. - Append
node_modulesand.worktrees/to the shared git exclude file so both trees stay clean. - Copy gitignored config (harness manifests,
.envfiles) into the worktree.
The worker edits files and runs tests in its worktree and never commits. The main tree stays clean.
Finish, by the main session:
- Review the diff with
git -C .worktrees/<card>-<slug> diff, thengit addandgit commitin the worktree. cdto the main repo root andgit merge --ff-only agent/<card>-<slug>, orgit cherry-pickwhen main has moved on.git worktree remove .worktrees/<card>-<slug>, thengit branch -d agent/<card>-<slug>.
rm -rf on a worktree directory leaves a stale entry in .git/worktrees/. git worktree prune clears it.
The pages in this series are written this way: one worktree per writer, no commits from the writer, and the parent reviews the diff, merges and removes the worktree.
Sharing one tree instead
Section titled “Sharing one tree instead”A worktree starts with empty submodules. In a repo with large ones (KiCad libraries, firmware, reference designs), git submodule update --init --reference per worktree took more than 25 s per module and timed out (2026-11-05). There the workers shared the main tree instead, with rules the worktree no longer enforces:
| Rule | Why |
|---|---|
| Only when the dispatching session owns the round: no loop and no other session in the repo | Otherwise the hazards above apply, and a worktree is the answer |
| Each worker gets an explicit list of files it may edit and files it must not touch | The file list is the isolation |
No tree-wide regenerators in a worker (make repro, a full make pcb, a repo-wide formatter) | They rewrite every worker’s files; one worker ran make repro by mistake and only luck kept it harmless |
| One worker owns the Makefile and CI (continuous integration) file for the round; the others return their lines as text | Two workers editing one Makefile is the classic collision |
| The parent runs the full gate set after the last batch lands, then commits per batch | A worker’s local test run does not see the others’ changes |
Four workers ran this way on one repo with no clash.
Main-session-only git
Section titled “Main-session-only git”On 2026-10-20 the harness stopped letting subagents and background workers run mutating git. The decision was based on 4 denials in 3,833 git approval prompts over 30 days, 2 of them misclicks (docs/plans/2026-10-20-command-git-safety.md). The guard extensions caught the leaks, but the prompt did not.
Workers edit files in the worktree the main session gave them, and the main session commits, merges and pushes. git-gh-gate.ts enforces it for any session with no UI:
// Workers (pi -p subagents, bg workers, loop agents: no UI) never run// mutating git, routine or not: they edit files in the worktree the// main session gave them, and the main session commits, merges and// pushes (user decision 2026-10-20).if (!ctx.hasUI) { audit("blocked"); return { block: true, reason: "Mutating git/gh is main-session only: subagents and background workers edit files in the " + "worktree they were given and leave committing, merging and pushing to the main session. Finish the file " + "changes and report what is ready to commit.", };}The same gate blocks no-UI write, edit and apply_patch calls that target .git/ paths. “Mutating” includes git add, git stash and git mv: a worker that renames files uses plain mv, and the parent’s git add -A records the renames. HEADLESS_WORKER_PREAMBLE repeats the rule in every bg_task prompt: “Mutating git … is blocked here: leave all git operations to the parent and describe what to commit in your final message.”
In the main session, routine local git (commit, push without force or delete, worktree add and remove, merge, switch, cherry-pick, revert, stash pop) runs without an approval prompt while the global git hooks are active. git worktree remove --force and git branch -D are not routine and still ask (isRoutineGit in lib/git-gh-gate-core.ts). On 2026-11-05 both prompts went unanswered while the user was away, the audit log recorded them as denied, and four empty worktrees stayed behind until the next session. For a clean worktree whose branch never moved, plain git worktree remove and git branch -d run unprompted. The pre-push gate runs gitleaks, blocked terms and sensitive-file checks on every push, and on public targets adds identifier shapes, provenance wording and an llmc review. Every auto-allowed command is logged. The tiers are in Running agent git commands without per-command approval prompts and the push checks in Agent leak gates.
/btw: side questions without interrupting
Section titled “/btw: side questions without interrupting”/btw <question> forks the current session into a read-only background worker. It answers from the full conversation history plus read-only lookups, and runs as a btw row in the agent view while the main turn keeps running (btw.ts). The finished answer is appended to the transcript as a btw-answer custom entry: it renders collapsed to 12 lines (ctrl+o expands), never enters the model’s context, survives /reload and /resume, and my session-history store ingests it as a kind=btw-answer row. Before 2026-11-07 the answer was a notification cut at 600 characters that scrolled away.
Before 2026-10-20, /btw sent the captured conversation to the model as a one-shot request and showed the answer in an overlay, with no tools and no way to add the answer to the conversation. The rewrite forks the session, so the worker has the parent’s history and model. On a provider with prompt caching the shared prefix is served from cache: the first request of a 2026-10-20 probe read 520k cached input tokens (btw.ts header).
The fork’s tool allowlist is BTW_TOOLS (lib/btw-core.ts:14): read, grep, glob, lsp, webfetch, websearch, web_research, codesearch, the docs_* readers, session_search, the cross-session history search tool, search_messages and the two context7 tools. Bash, write and edit are not on it. The worker session persists under the parent’s subagents/ directory like task workers, so my session-history store ingests it.
| Command | Effect |
|---|---|
/btw <question> | Fork and ask |
/btw | List this session’s side questions |
/btw add [n] | Add answer n (default: the latest) to the main conversation as a user message |
/btw fork [n] | Copy answer n’s worker session into the normal session directory as a new top-level session (parentSession = the worker file, so /resume lists it) and switch to it with full tools. /resume returns to the main session. |
/undo: file-level undo
Section titled “/undo: file-level undo”/undo restores the conversation and the files the agent changed. Restoring only the conversation leaves the files in the half-state the agent just edited, and the next turn starts on broken files (session-undo.ts).
Mechanism, lazy pre-image capture:
- On
tool_callforwrite,edit,write_streamandapply_patch, the extension records the bytes on disk before the tool runs, the first time a path is touched in a turn. - On
tool_result, it records the bytes after. - Pre-images live in a content-addressed shadow store outside the project:
~/.local/state/pi-undo/<session-id>/objects/<sha256>. The root isPI_FILE_UNDO_DIR. - On
/undo, it compares each touched file’s current bytes with the post-image. An unchanged file gets its pre-image back. A file changed since the agent’s edit (by a human or another session) is skipped with a warning. - It then forks the conversation before the most recent user message and restores that prompt into the editor.
Limits:
- bash writes are not snapshotted, only the four file tools.
- Skipped: gitignored files,
node_modules,.git, build directories, files over 5 MiB, and anything outside the session cwd. - The in-memory index is empty after a pi restart, so
/undofalls back to a conversation-only fork. - With no UI,
/undorefuses instead of restoring files silently.
PI_NO_SESSION_UNDO=1 disables the extension. PI_FILE_UNDO_OFF=1 keeps the conversation fork and drops the file restore.
Decision diagram: which worker for which job
Section titled “Decision diagram: which worker for which job”The same decision as text:
- A side question while the main turn runs goes to
/btw. - Work whose result the parent reads before continuing goes to
task:explorewhen it is read-only,generalwhen it needs full tools, one call per independent angle. - A plain shell command (polling, build, download) goes to
bg_bash. - A self-correcting loop or loop graph goes to
bg_loop. - Any other long delegated work goes to
bg_task.
Related docs
Section titled “Related docs”- Loop or graph: a sensor-gated coding-agent loop - the loop agents spawned through
bg_loop - The guard extensions that police agent tool calls - the gates that block workers from running git
- A cross-client memory store for coding agents - worker session persistence and ingestion into the session-history store
- The secret guard: keeping credentials out of agent transcripts - the gate that blocks secret values in tool arguments
- Watching and steering coding-agent sessions from a phone - a dashboard that lists these workers under their sessions and steers them through the inbox, with phone pushes
- Which model runs which agent work - which model each worker kind starts on, and the guards on each provider path
Linked from
- A NixOS mini PC as a second dev box beside a WSL2 desktop
- Agent image generation and LoRA training
- apm, an APM counter that adds no input latency
- Context, prompt cache, and compaction in a coding-agent harness
- Generating and checking the GRIDDLE LX PCB from code
- Guard extensions that enforce prose and process rules in a coding agent
- History of the pi coding-agent harness
- Lockstep: watch-party sync for Jellyfin
- Model routing in a coding-agent harness
- Resuming any coding-agent session from any directory
- Reverse engineering with a coding agent and headless Ghidra
- Running board cards through agent loops as waves with foreman
- Sharing guards and tools between two coding-agent harnesses
- Tool-output pruning and the prompt cache: a replay of long agent sessions
- Watching and steering coding-agent sessions from a phone