Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
High-performance AI coding agent CLI written in Rust with zero unsafe code
Jump to setup instructionsFetched from the repository for this visit.
pi_agent_rust - Native AI coding agent CLI written in Rust
Why Should You Care? • TL;DR • Methodology • Quick Start • Features • Installation • Commands • Configuration • User Guide
# Requires Minisign: brew install minisign (macOS), sudo apt install minisign (Debian/Ubuntu)
# Install latest release
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | bash
| What you need | Guide |
|---|---|
| Use Pi | Quick start, commands and shortcuts, settings |
| Set up language servers | Supported servers, installation, and automatic detection |
Find /goal | Version and interface availability, terminal quick start |
| Give the agent project instructions | Skills, prompts, and context files |
| Develop Pi or integrate with it | Contributor and API references |
See the documentation home for the full user guide. These docs
describe main; use your release tag for version-matched documentation. Keep
the full pi --version output, including the commit hash, when reporting a
missing command.
You want an AI coding assistant in your terminal, but existing tools are:
pi_agent_rust is a from-scratch Rust port of Pi Agent by Mario Zechner (made with his blessing!). Official release archives install the single end-user binary pi, with streaming responses and 36 built-in tools (19 in the default --tools list; 14 always in the model's schema, the rest reachable through the xdev dispatcher or enabled in settings).
This project is no longer trying to be a strict drop-in replacement for the legacy TypeScript Pi. That target became both impractical and undesirable as the legacy implementation evolved. Legacy Pi remains useful historical context, but it is not our compatibility authority or definition of completeness.
OMP is the closer reference for where the product is going: feature surface, agent workflows, look and feel, and overall UI/UX. Pi Rust still chooses Rust-native architecture and may intentionally differ from both projects when that produces a simpler, safer, or better coding agent. Historical drop-in and parity artifacts remain in the repository as records; they do not gate product work, releases, or user-facing claims.
All repository quality checks, builds, and releases run through Doodlestein
Self-Releaser (DSR). Contributors must not invoke Cargo or RCH directly, and
GitHub Actions is never an execution or evidence authority for this project.
Use dsr quality --tool pi_agent_rust for the registered quality recipe and
the canonical DSR build/release commands documented in
docs/releasing.md.
For signed published payload verification and offline CLI smoke checks, see Published release consumer checks.
Rather than a direct line-by-line translation, this port builds on two purpose-built Rust libraries:
# Start a session
pi "Help me refactor this function to use async/await"
# Continue a previous session
pi --continue
# Single-shot mode (no session)
pi -p "What does this error mean?" < error.log
If you already use Pi Agent, especially through OpenClaw, this project keeps the core workflow while upgrading the engine under the hood:
Security is a first-class design goal here, not a bolt-on:
tool/exec/http/session/ui/events)exec enforcement: capability gate first, then command mediation that blocks critical shell classes by default (for example recursive delete, disk/device writes, reverse shell) and can tighten to block high-tier classes in strict/safe policypending -> acknowledged -> trusted -> killed) with kill-switch audit logs and explicit operator provenanceasupersync for more predictable cancellation/lifecycle behaviorThe Rust port is designed around large-session, multi-agent, and extension-heavy workloads. Release-facing performance numbers are published only when the checked-in evidence artifacts are current, have matching run provenance, and show data and a passing result for every declared budget, with no data-contract failures. Historical benchmark snapshots are retained in planning/evidence artifacts, but they are not treated as current README claims until the performance evidence gate is regenerated cleanly.
Extension runtime guarantees are also concrete:
| Extension assurance signal | Why you should care |
|---|---|
Two-stage exec guard (exec capability policy + command-level mediation + DCG/heredoc AST signals) | Dangerous shell intent is caught before spawn, including destructive payloads hidden in multiline wrappers |
Trust lifecycle + kill switch (pending/acknowledged/trusted/killed) | You can quarantine an extension instantly, log who pulled the switch and why, and require explicit re-acknowledgement before restoring access |
Hostcall lane kill-switch controls (forced_compat_global_kill_switch, forced_compat_extension_kill_switch) | Fast-path regressions can be contained immediately by forcing compatibility-lane execution without disabling the extension system |
Opt-in hostcall reactor telemetry harness (enable_hostcall_reactor: shard routing, bounded queue backpressure, optional NUMA slab tracking) | Lets stress harnesses and operators inspect shard backpressure and fallback transitions on demand without adding mutex/clone overhead to default inline fast-lane dispatch |
| Cold owner-isolated JS realms + persistent transpile cache | Every reload gets a fresh realm while versioned disk-cached transpilation avoids treating mutable JavaScript state as safely reusable |
Tamper-evident runtime risk ledger (verify / replay / calibrate) | Security decisions are hash-linked and can be replayed or threshold-tuned from real runtime traces |
Bottom line: Pi's architecture targets lower latency, lower memory use, and stronger extension runtime safety under real workload pressure; current numeric claims must come from fresh, provenance-matched evidence artifacts.
Data source: docs/planning/BENCHMARK_COMPARISON_BETWEEN_RUST_VERSION_AND_ORIGINAL__GPT.md (latest secure-path + full orchestrator checkpoints, 2026-04-23).
Release-facing numeric performance claims in this README include inline citations with format:
*(from [artifact-path], run [correlation-id])*
Example: *(from [artifact-path], run [correlation-id])*
Two additional machine-recognized citation forms exist:
*(from [artifact-path])* — path-only citation. The cited artifact must
exist and parse; freshness is enforced by the same 14-day rule as
release-facing claims.*(from [artifact-path]; historical snapshot)* — explicit historical
contract. The citation itself declares the obligation a retained snapshot:
existence and validity are still checked, but staleness is not enforced
because such claims never satisfy current release-facing requirements.scripts/check_readme_evidence_freshness.py (Check 10 in the registered DSR
quality recipe .dsr/repos.yaml and listed in
docs/releasing.md) checks file freshness and artifact content so stale, no-data, or
correlation-mismatched evidence cannot back user-facing performance claims;
for release-facing citations of budget_summary.json it validates the full
pi.perf.budget_summary.v2 contract, including that the header counts equal
the per-budget rows. It reports line-numbered proof obligations for cited
claims and extracts claim-gated performance phrases for reviewer audit.
Historical snapshot citations are mapped separately and do not satisfy current
release-facing claims.
In this README, we means the project owner and collaborating coding agents.
The design concentrates performance work in several runtime layers rather than
assuming one optimization proves an end-to-end result.
| Technique | What we do | Runtime intent |
|---|---|---|
| Cold-start minimization | Single native binary, no Node/Bun runtime bootstrap, no JIT warmup, startup prewarm for extension runtime paths | Reduce time-to-first-interaction |
| Less copying on hot paths | Arc/Cow message flow, zero-copy hostcall/tool payload handling, reduced clone-heavy provider/session paths | Reduce CPU and allocation pressure |
| Deterministic dispatch core | Typed hostcall opcodes, inline fast-lane/compat-lane routing, kill switches, and opt-in reactor-mesh backpressure telemetry | Keep common hostcalls fast while preserving predictable fallback and observability under load |
| Efficient long-session storage | SQLite session index + v2 sidecar (segmented log + offset index) with O(index+tail) reopen path | Avoid full-history work on eligible resumes |
| Streaming parser tuned for real networks | SSE parser tracks scanned bytes, handles UTF-8 tails, normalizes chunk boundaries, interns event-type strings | Reduce repeated scanning and parser stalls |
| Safe fast-path controls | Shadow dual execution sampling, automatic backoff on divergence/overhead, compatibility-lane kill switches for containment | Bound optimization risk and preserve fallback behavior |
| DSR performance governance | Scenario matrices, strict artifact contracts, fail-closed perf gates | Detect regressions before release |
If you want the full implementation inventory, see Performance Engineering.
The benchmark evidence policy is designed to keep results realistic, reproducible, and hard to game.
What we measured:
100k up to 5M token-class session states.--help, --version) separately from long-session workflows.How we kept comparisons fair:
pi_agent_rust vs legacy coding-agent)How we kept claims honest:
If you want full details, see:
docs/planning/BENCHMARK_COMPARISON_BETWEEN_RUST_VERSION_AND_ORIGINAL__GPT.md (methodology + results + caveats + raw artifact paths)| Feature | Pi (Rust) | Typical TS/Python CLI |
|---|---|---|
| Startup | Native single-binary path (Fresh comparative measurement pending; historical pre-v0.3.0 criterion: ~5-7ms p95 version, ~12-15ms help; see tests/perf/reports/budget_summary.json startup_version_p95 and startup_full_agent_p95) | Runtime-dependent |
| Binary size | Speed-optimized release profile (LTO, strip, opt-level = 3); the binary_size_release budget and its latest stripped-artifact measurement are reported in Current Evidence State, never promoted here until claim readiness is ready | Runtime-dependent |
| Memory (idle) | Bounded-resource design; the idle_memory_rss budget and its latest release-binary measurement are reported in Current Evidence State (docs/perf-budgets-recipe.md defines the canonical 5-measurement taxonomy) | Runtime-dependent |
| Streaming | Native SSE parser | Library-dependent |
| Tool execution | Process tree management | Basic subprocess |
| Sessions | JSONL with branching | Varies |
| Unsafe code | Forbidden | N/A |
# 1) Start an interactive session
pi
# 2) Ask a codebase question
pi "Summarize the architecture in src/"
# 3) Attach a file inline
pi @src/main.rs "Explain startup flow"
# 4) Run single-shot mode for scripting
pi -p "List likely regression risks for this diff"
# 5) Continue your last project session
pi --continue
# 6) Inspect available models/providers
pi --list-models
pi --list-providers
asupersync is a structured concurrency async runtime designed for applications that need predictable resource cleanup. Key features used by pi_agent_rust:
Cx): Async functions receive an explicit context that controls what they can do (HTTP, filesystem, time). This makes testing deterministic.pi_agent_rust runs on asupersync end-to-end today (runtime + HTTP/TLS + cancellation). Provider streaming uses a minimal HTTP client (src/http/client.rs) feeding a custom SSE parser (src/sse.rs).
rich_rust is a Rust port of Will McGugan's Rich Python library. It provides:
[bold red]error[/] renders as bold red textThe terminal UI uses rich_rust for all output formatting, providing the same visual quality as Rich-based Python tools.
Install Minisign first (brew install minisign on macOS, or sudo apt install minisign
on Debian/Ubuntu). The installer uses it to authenticate project releases.
# Install latest release binary
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | bash
If you already have the original TypeScript pi installed, the installer asks
whether to make Rust Pi canonical as pi and automatically create legacy-pi
for the old command.
export ANTHROPIC_API_KEY="sk-ant-..."
# Interactive mode
pi
# With an initial message
pi "Explain this codebase structure"
# Read files as context
pi @src/main.rs "What does this do?"
ollama, llamacpp (llama.cpp's llama-server), mistralrs (mistral.rs), and
lmstudio are built-in local providers. The first three need no API key and
work out of the box against their default ports:
pi --provider ollama --model llama3 -p "hi"
pi --provider llamacpp --model <gguf-repo-id> -p "hi"
pi --provider mistralrs --model default -p "hi"
To point at any other OpenAI-compatible server (a custom host/port, vLLM, etc.),
add it to ~/.pi/agent/models.json:
{
"providers": {
"ollama": {
"api": "openai-completions",
"baseUrl": "http://127.0.0.1:11000/v1",
"apiKey": "ollama",
"models": [{ "id": "Qwen3.6-35B-A3B-4bit", "contextWindow": 32768 }]
}
}
}
Then pi --provider ollama --model Qwen3.6-35B-A3B-4bit. See
docs/models.md for the full models.json schema, provider
aliases, and secret resolution (env vars and !command shell lookups).
For OpenAI-compatible providers, model discovery is a standalone command: it prints one model ID per stdout line and exits without starting the TUI.
# Use a successful live response or (with a warning on stderr) the static
# registry when live discovery is unavailable
pi --fetch-models openrouter
# Bypass the cache and require a genuinely live response; never fall back
pi --fetch-models openrouter --refresh-models
# Make a successful live/cache catalog available to future --list-models and
# interactive /model pickers
pi --fetch-models openrouter --refresh-models --persist-models
Each standalone CLI invocation starts a new process, so its in-memory cache is
fresh. The five-minute cache only avoids repeat discovery calls made within one
long-lived process by SDK/library users; --refresh-models bypasses that cache.
Discovery also reads usable supported_reasoning_levels advertisements, including
metadata.supported_reasoning_levels and entries shaped as {"effort":"high"}.
Nested metadata takes precedence. Pi preserves the advertised tiers through the
cache and persisted catalog, constrains the model's thinking choices to those
tiers, and sends the selected effort through the provider's request format.
The recognized tiers are off (also advertised as none), minimal, low,
medium, high, xhigh, and max. Missing, empty, or unusable advertisements
leave existing model capabilities intact. Your configured thinking level remains
authoritative; discovery does not select a server-advertised default effort.
Model discovery also retains advertised serving tiers (service_tiers, including
metadata.service_tiers) through the cache and saved catalog. In either terminal
frontend, /fast ultrafast (also /fast ultra) selects an advertised ultrafast tier; /fast priority,
/fast flex, /fast scale, /fast default, /fast off, and /fast status are
also available. /fast on preserves an existing priority or ultrafast choice.
Custom OpenAI routes require an explicit model advertisement or a manual
serviceTiers declaration, and requests omit unsupported tiers after switching
models. Discovery never changes your selected tier. See model configuration
for metadata precedence and provider behavior.
Persistence is opt-in. The v2 ~/.pi/agent/models.fetched.json schema stores
provider/model IDs, optional bounded reasoning and serving tiers, the fetch timestamp, and a non-secret SHA-256 identity
binding membership to the provider, API, query-free endpoint, auth-header
mode, recognized credential-query ordered name/presence shape, and
request-header name/presence shape that produced it. Pi never persists a static fallback, API
credentials, URL query values, or request-header values—not even as
offline-verifiable hashes. Credential-channel values are rotation-tolerant.
Any non-empty query/header value outside a narrowly recognized credential
channel may identify a tenant or deployment, so Pi refuses to persist that
catalog (and ignores legacy persisted rows for such a current route) rather
than reuse unverifiable membership. If a safely bound route shape no longer
matches, Pi ignores those generated rows and reports how to refresh them.
Credential rotation alone does not invalidate the catalog. The generated
membership is likewise not account-bound: switching accounts on the same
endpoint/transport shape can retain the prior account's saved model list until
you rerun --fetch-models <provider> --refresh-models --persist-models.
Inference still resolves and sends the current account's credential; only the
opt-in model-membership list can be stale across that switch. The generated
catalog is loaded first; your hand-written ~/.pi/agent/models.json is loaded
afterward and remains authoritative. Pi does not rewrite or merge that
user-authored file.
Legacy pi.models.fetched.v1 files cannot be rebound safely because they lack
this provenance, so Pi preserves them instead of overwriting them. Move the
legacy file aside to models.fetched.v1.backup.json, then rerun the verified
live refresh and persist command above to create a v2 catalog.
Real-time response streaming with extended thinking support:
pi "Write a quicksort implementation"
Watch the response appear incrementally, with thinking blocks shown inline.
Tools are tiered so the model's live schema stays small while everything
remains reachable. The tier table and default enabled list live in
src/xdev.rs; src/cli.rs resolves CLI selection and optional-tool settings:
read, write, edit,
bash, grep, find, ls, hashline_edit, ask, todo,
web_search, submit_plan, current_time, xdevxdev list/describe/run/promote): ast_grep, ast_edit, lsp,
debug, manage_skill — plus the memory-bank tools (retain,
recall, reflect, memory_edit, learn) when memory.backend is
local or cass (local memory plus read-only project history)jobs (background bash job control) and hub (PTY
service supervision), alongside the essential tier. The default --tools
list names 19 tools; the registry adds manage_skill by default and, when any
discoverable tool is enabled, the xdev dispatcher--tools opt-in extras: eval (tools.enableEval),
github (tools.enableGithub), security_scan
(tools.enableSecurityScan)settings.json):
browser (browser.enableBrowser), computer
(computer.enableComputer), the media trio inspect_image,
generate_image, tts (media.enableInspectImage /
media.enableGenerateImage / media.enableTts), and read_media
(media.enableReadMedia; inline video/audio for Gemini-family models)subagent (tools.enableSubagent or --tools; it can
start additional coding-agent processes)| Tool | Description |
|---|---|
read | Read files (images and http(s)/skill://-style URLs supported) |
write / edit / hashline_edit | Create, surgically replace, or hashline-anchored edit files |
bash | Shell with timeout, command mediation, optional PTY, background jobs |
grep / find / ls | In-process content search, file discovery, listing |
web_search | Ranked multi-provider web search with circuit breaking |
ask / todo | Structured mid-turn option cards; persistent session task list |
submit_plan | Submit a completed plan for approval when plan mode is active |
current_time | The host's wall-clock time: UTC and local ISO-8601 timestamps, the UTC offset, Unix epoch seconds, weekday, and ISO week (the local zone follows TZ); takes no arguments. The system prompt carries only the date so the cached prefix stays stable; this tool is the clock |
xdev | Dispatcher exposing the discoverable tier (list/describe/run/promote) |
ast_grep / ast_edit | Structural code search and rewrite |
lsp / debug | Language-server (14 ops) and DAP debugging (29 ops) bridges |
eval | Persistent Python and JS kernels with cell semantics |
jobs / hub | Background bash job control; PTY service supervision |
github | gh-backed PR/issue/run operations |
security_scan | Rule-pack security scanning to SARIF (plan/run/disposition/compare) |
manage_skill + memory tools | Managed skills CRUD; opt-in project memory bank |
browser | Headless Chromium automation over CDP (navigate, snapshot, click, type, screenshot) with a domain allowlist; settings-gated |
computer | Desktop automation (displays, windows, screenshots, mouse/keyboard, clipboard); mutating actions require approval; settings-gated |
inspect_image / generate_image / tts | Vision analysis of local images, image generation/editing, and text-to-speech through provider adapters; settings-gated |
read_media | Attaches a local video/audio file (mp4, webm, mov, mp3, wav, m4a, ogg, flac) as a native media block (stored in session blob sidecars and staged via the Gemini Files API when large). Gemini, Gemini CLI, and Vertex Gemini models receive it natively; OpenAI audio-capable Chat models consume WAV/MP3; every other provider sees [media omitted: <name>, <mime>, <size>]. Hard cap 64 MiB per file (media.maxBytes); settings-gated |
subagent | Delegate isolated work to named Rust Pi child agents |
The local memory bank can extract reusable facts, lessons, preferences and
decisions from completed saved sessions, and consolidate facts learned earlier.
Enable the bank in settings, then run /memory sync in the default interactive
UI to learn from the current completed branch:
{
"memory": {
"backend": "local",
"autoExtract": true,
"extractEveryTurns": 3
}
}
autoExtract is off unless explicitly enabled. When enabled, one bounded,
tool-free request runs after every three newly authored turns by default; the
cadence accepts 1–100. The request uses the session's current model and provider
credentials, has a 30-second deadline, and shares any remaining foreground time
budget. Extraction failure leaves the completed foreground answer intact and
can be retried with /memory sync. Explicit synchronization works with
autoExtract off. Ephemeral sessions and delegated child agents do not extract
project memories. The cass backend uses the same local learning pipeline.
Extraction resolves the session's current attached workdir, screens complete
bounded text evidence before selecting a recent request window, and redacts
both request and stored results. Oversized evidence is refused rather than
partially screened. Each successful extraction commits facts, search indexes,
audit records and a durable branch checkpoint together, so reopening or revisiting
an already synchronized branch does not repeat the provider request. Automatic
consolidation can supersede only unchanged generated memories supplied to the
request; manually retained or edited facts keep their ownership. Historical
versions remain auditable. Learned facts become available through recall,
reflect and the existing startup memory block. /memory view, list, search
and forget remain available for inspection and management.
All tools include automatic truncation for large outputs (2000 lines /
1MB), detailed metadata in responses, and process-tree cleanup for bash.
Background-job logs live in a dedicated directory with a 256 MiB / 4096-entry
budget. When it cannot admit another 16 MiB artifact, Pi deletes the oldest
unlocked logs, only as many as needed, and always keeps active logs and at
least eight recent ones. Set PI_JOBS_ARTIFACT_RETENTION=preserve to keep
every log instead; Pi then refuses new background jobs once the budget is
full. Job snapshots report the applied policy, removed-file count, and
reclaimed bytes in artifactCleanup. A cancelled shell job reports status: "killed".
Its exitCode contains the shell's numeric exit code when the operating system
provides one, including an exit code returned by a signal handler. A Unix
shell terminated directly by a signal has a null exitCode.
Print mode can keep working after a background job finishes. Add --wait-async
or set "async": {"printWake": true} to wait for the current session's jobs,
deliver their completion notices to the agent, and run follow-up turns in the
same session. A follow-up may start further jobs. The process exits when all
owned work has settled and its notices have been delivered. Text continues
streaming each answer; JSON mode emits the corresponding agent lifecycles.
pi -p --wait-async --max-time 3600 \
"Run the integration suite in the background and fix any failures."
The flag is opt-in; ordinary print mode exits after its prompts and cancels
unfinished jobs. With async waiting, --max-time covers the original run,
idle waits, follow-up turns and retry delays. Reaching it fails the run and
cancels owned jobs. Ctrl+C also interrupts idle waits and retry delays.
Hub service logs retain the first 16 MiB of raw output per run. Pi continues
draining the service after that limit or an artifact write failure, so live
tail logs, readiness checks, and PTY input continue working. logs, ps, and
describe report logCapture byte counts, truncation, I/O errors, and output
drain state separately from process status; incremental reads also report
evicted lines. The cap applies to each artifact, not the total across runs.
detached: true skips session-exit cleanup, but the PTY and its supervisor
still belong to the current Pi process: cross-process reattachment and
survival after that host process exits are not implemented.
To enable optional tools across launches, add their flags to the existing
tools object in ~/.pi/agent/settings.json or a trusted project's
.pi/settings.json:
{
"tools": {
"enableEval": true,
"enableGithub": true,
"enableSecurityScan": true,
"enableSubagent": true
}
}
Each flag defaults to false and also accepts snake_case (enable_eval,
enable_github, enable_security_scan, enable_subagent). With no --tools
argument, enabled extras join the existing defaults. An explicit --tools
list overrides these flags for that run, even if it equals the default list.
--no-tools and an empty, whitespace-only, or comma-only --tools value disable
all built-ins, including settings-gated extras. Extensions and MCP servers retain
their own loading controls. Trusted project flags override global flags
individually, including false; untrusted project settings are excluded.
Existing approval policies and native child-agent allowlists still apply.
See Optional-tool settings.
Per-tool exposure is configurable via tools.loadMode.<name> set to
essential, discoverable, or off. A configured off entry excludes a tool
from implicit selection, including tools automatically added by settings and
manage_skill. An explicit --tools name overrides that exclusion without
enabling a separate backend such as the memory bank. The generated xdev
dispatcher remains disabled by tools.loadMode.xdev: "off". Load modes do not
activate an optional tool by themselves. An explicit tool selection remains available:
pi --tools read,bash,edit,write,grep,find,ls,hashline_edit,subagent \
"Use the scout agent to inspect the provider implementation."
Use --warn-cost to show a one-time notice and --max-cost to stop admitting
model requests once known spend reaches a USD threshold:
pi --warn-cost 2 --max-cost 5 "Implement and test the change."
pi -p --wait-async --max-cost 10 "Delegate the investigation and report the findings."
The corresponding settings are session.warnCost and session.maxCost;
CLI values override them. Values must be positive finite numbers. The limits
cover the active session tree: foreground turns, retries, native subagents,
advisor reviews, compaction, titles, memory extraction, side questions, native
image inspection and supported image-generation billing share the same account.
See media spend accounting for
supported billing units and unpriced media cases. Child requests consult the parent's live balance;
missing or ambiguous accounting acknowledgements block further child requests.
Known partial usage from an in-flight request counts toward the next admission. The provider's final bill replaces that request's provisional estimate exactly once, including when the final bill is lower. Cancelling or reaping a native child retains partial usage already acknowledged by its parent, so siblings cannot spend that allowance again. An already-admitted request may settle its bill during cancellation; this does not permit new model requests.
{
"session": { "warnCost": 2, "maxCost": 5 }
}
Resuming includes recorded assistant usage from all retained branches and saved auxiliary-spend checkpoints. Forking, rewinding, retrying, changing models and reloading resources preserve the live balance. A new session gets a fresh balance; switching to another saved session restores that session's recorded spend. A resumed session already above its warning threshold does not repeat the warning. Change launch flags or settings before reopening to use different thresholds.
The Rust SDK exposes SessionOptions.warn_cost, max_cost and an optional
shared cost_budget; CostBudget clones share one account. Warnings arrive
as AgentEvent::CostWarning (type: "cost_warning" in JSON). A refused request
returns Error::CostCap; print mode exits with status 5 (EXIT_CODE_COST_CAP; status 3 is reserved for non-interactive approval unavailability). Native RPC marks
the terminal failure with errorCode: "cost_cap", retryable: false, and
costCap: { "spent": ..., "cap": ... }.
These are request-boundary limits based on known provider costs or catalog
token pricing. Requests already in flight may finish above the cap, and
unreported/unpriced usage cannot be estimated. Spend is checkpointed with
session saves, including normal turn completion, replacement and SDK shutdown.
Only settled charges enter saved cost checkpoints; an in-flight estimate
cannot permanently inflate the restored balance if its final bill is lower.
A live AgentSession activates its cost journal beside the session file after
a cost checkpoint is successfully saved and acknowledged. Later finalized
charges become recoverable once their journal writes are acknowledged, without
another transcript save. Replacing or shutting down that session retains the
same journal destination for captured background requests, without rewriting
the transcript or racing a newly reopened session's saves. Resume
combines those charges with saved checkpoints exactly once; a reopened live
account also imports newly arrived charges before admitting another request.
This applies to JSONL and SQLite sessions, including the first charge arriving
after a zero-spend checkpoint. Failed replacements and same-file reloads keep
the foreground account live. Cost journals are not created for --no-session.
Saved forks retain references to observed unfinished billing writers. A fork can recover their final charges even after every foreground handle has closed, without opening an ancestor's transcript or SQLite database. Repeated forks of one live account use the same journal. Once a writer's final closure is observed, later checkpoints retain its final total and remove the completed reference. Missing required journals or writers block further requests instead of resetting spend.
Keep the adjacent .pi-cost-*.json files with their session files when backing
up a session directory. Unfinished references use the original absolute journal
location: moving or copying the directory does not redirect outstanding billing
to the copy. Observe final closure and save a new checkpoint before expecting a
snapshot to be independent of its original journals. Failure to acknowledge a
journal write blocks further requests on the affected account. If an incomplete
save leaves primary usage and journal charges with an uncertain overlap, the
known lower bound is retained and further requests are blocked. Saved sessions
with a cost account now save and acknowledge their initial checkpoint before
extension startup hooks or the first provider request. If that save fails,
startup and further provider requests are blocked; sessions without a cost
account and ephemeral sessions retain their lazy persistence behavior. A crash
before a final charge receives its durable acknowledgement can still lose
unacknowledged spend; these limits do not replace the provider's billing records.
Rust Pi includes a native subagent tool; it does not depend on a QuickJS
extension and never resolves a child executable by assuming a pi binary on
PATH. By default it starts the current Rust Pi executable. Set
PI_SUBAGENT_PI_BINARY=/absolute/path/to/rpi only when an explicit binary
override is needed.
Enable it persistently with "tools": { "enableSubagent": true } in
settings.json, or include subagent in an explicit --tools list. It remains
off by default; see built-in native subagents
for the bundled agent profiles.
Agent definitions are Markdown files in $PI_CODING_AGENT_DIR/agents/*.md
(normally ~/.pi/agent/agents/*.md) or the nearest
.pi/agents/*.md. Project definitions require workspace trust before they can
override same-named bundled or user definitions. The trust digest includes the
selected directory and its Markdown files, including a directory inherited
from an ancestor workspace, because profiles choose child tools, models, and
instructions. Enabling subagent does not grant that project authority.
Untrusted workspaces retain bundled and global agents; scope: "user"
excludes project profiles explicitly. A scoped grant is revalidated before
project discovery, so changed profiles require a fresh launch and trust decision.
The process inherits the parent's provider, router, authentication, and
model-registry environment, including PI_CODING_AGENT_DIR.
Children choose their model in this order: the agent definition's model: pin,
the configured task role (or smol fallback), then the parent's active provider
and model. Each request captures the parent selection once, including any
manual switch or failover already in effect; queued children, chain steps,
schema retries, and explicit revivals retain that selection. Children resolve
credentials from their inherited environment and existing authentication
configuration. Credentials supplied only to the parent's CLI or in memory are
not copied into child arguments or new environment variables.
---
name: scout
description: Inspect code and return concise, evidence-backed findings.
model: ai-router/gpt-5.6-sol
reasoning: low
tools: read,grep,find,ls
skills: ../skills/codebase-archaeology/SKILL.md
---
Read relevant code before answering. Do not edit files.
The tool accepts exactly one workflow shape: a single { agent, task }, a
bounded parallel tasks array (up to 8, default concurrency 4), or a sequential
chain array. In chains, {previous} in a task is replaced by the preceding
child's final output. Children run headlessly in isolated ephemeral sessions,
stream progress into the parent TUI/JSON output, return structured status and
stderr details, and are killed/reaped if the parent is cancelled. Child agents
receive the declared tool allowlist; the default child allowlist deliberately
excludes subagent to prevent accidental recursive delegation.
An individual task can select an exact model: "provider/model:thinking" or
an explicit configured role, such as model: {"role": "smol"}. Role selections
require a trusted modelRoles assignment and are resolved before any child,
worktree, or job starts. The selected model, thinking level, and role-specific
fallback policy remain fixed for queued tasks and reusable workers or pools.
See subagent model selection for the supported
roles and refusal behavior.
With per-task isolation: "worktree", a parallel batch captures each source
workspace before launching children, including staged, unstaged, and untracked
files. Queued children and corrective retries use that same baseline. Accepted
patches apply after execution in task order; conflicts and cancelled work remain
in their worktrees for inspection. isoApply: "keep" retains a result without
applying it, and isoApply: "drop" discards its worktree after reporting the patch.
Fresh git init repositories are supported before their first commit: a private
root snapshot preserves the parent's branch and staging state during delegation.
In interactive mode, /tan <work> starts the same task-role child machinery
without interrupting the main conversation. The child runs in the current
directory, appears in hub agent roster with kind=tan, and sends its bounded
completion summary through the follow-up queue at the next idle turn boundary.
Because /tan inherits the delegation safety gate, it is available only when
the opt-in subagent tool is enabled. It captures the same model precedence when
the command is submitted, so a later parent model switch does not retarget it.
Native children include hub in their default tool set and can exchange messages
with other children of the same live parent session. Agent definitions with an
explicit tool allowlist must include hub to enable this capability. A child's
hub call with {"op":"agent","action":"roster"} returns its authenticated
selfId and the parent's child roster. Use those run IDs as recipients:
{"op":"agent","action":"send","name":"receiver-1","text":"The parser change is ready."}
{"op":"agent","action":"inbox"}
{"op":"agent","action":"send","name":"parent","text":"I found a blocking dependency."}
Child controls, parent inboxes, accepted agent:// results, and background
job delivery retain their originating live session. Separately loaded handles
of the same saved session have independent child authority; cloned SDK scopes
share it. /hub, /tan, retained workers, and pooled delegation use that same
ownership, including during cancellation and cleanup. The low-level SDK's
explicit durable-owner job observation and teardown APIs remain owner-wide.
SDK handle shutdown and replacement retire only that handle's live job scope,
including shell jobs, foreground shell calls, editor terminals, subagents,
/tan, and persistent workers from sessions previously selected within it.
The admission fence and cancellation requests are installed before waiting for
session saves or locks. Dropping shutdown leaves the fence closed. Awaiting it
waits within bounded budgets for process reaping, output draining, editor
terminal release, isolated writeback disposition, and accepted-result retention.
Dropped foreground calls retain cleanup ownership through the native reaper or
editor release acknowledgment. Unfinished cleanup and lost acknowledgments are
reported instead of treating a cancelled roster entry as proof of process exit.
Discarding a replacement candidate cannot stop an active handle's work merely
because both loaded the same saved session. Bound SDK read and grep calls
also resolve agent:// results through the same live owner as native delegation.
Sibling messages enter the recipient's steering queue between turns and remain
available in its inbox. The parent reads child reports with
{"op":"agent","action":"inbox","name":"parent"}. Inbox pages return
nextCursor, hasMore, and oldestCursor; pass nextCursor as
cursor to request later messages. Each recipient retains its latest 64
messages, so clients can use oldestCursor to detect that earlier messages
have fallen outside retention.
The parent authenticates the child's sender identity. Children can read their own inbox, list peers, and send to a live sibling or the parent; transcript, steering, kill, and revival controls remain on the parent surface. The local connection closes when its owning child run ends or is cancelled.
Sessions persist as JSONL files with full conversation history:
# Continue most recent session
pi --continue
# Open specific session
pi --session ~/.pi/agent/sessions/--home-user-project--/2024-01-15T10-30-00.jsonl
# Ephemeral (no persistence)
pi --no-session
Sessions support:
Enable deep reasoning for complex problems:
pi --thinking high "Design a distributed rate limiter"
Thinking levels: off, minimal, low, medium, high, xhigh, max
SKILL.md under .pi/skills/, .agents/skills/, ~/.pi/agent/skills/, or ~/.agents/skills/ and invoke it with /skill:name. See skill discovery and precedence.~/.pi/agent/prompts/ or .pi/prompts/; invoke via /<template> [args].pi install npm:@org/pi-packages (skills, prompts, themes, extensions).Pi provides context-aware autocomplete in the interactive editor:
@ file references: Type @ followed by a path fragment to attach file contents. The completion engine indexes project files (respecting .gitignore) via the ignore crate's WalkBuilder, capping at 5,000 entries./ slash commands: 40+ built-in commands (see the slash-command table below) and user-defined prompt templates and skills all appear as completions.Pi runs in four modes, each suited to different workflows:
| Mode | Invocation | Use Case |
|---|---|---|
| Interactive | pi (default) | Full TUI with streaming, tools, session branching, autocomplete |
pi -p "..." | Single response to stdout, no TUI, scriptable | |
| RPC | pi --mode rpc | Headless JSON protocol over stdin/stdout for IDE integrations |
| ACP | pi --acp | JSON-RPC 2.0 Agent Client Protocol over stdin/stdout (e.g. the Zed editor) |
Browser access to interactive mode. pi web provides a supervised loopback
companion with local approval for each proposed prompt. pi web --terminal
provides a terminal mirror with a locally approved, revocable control lease and
a separate browser composer. Both require the native FTUI and a local terminal;
the mirror uses fullscreen rendering and adds explicit Tailscale/LAN options.
See web access for the two modes' controls, privacy,
and limits (src/web_remote/, src/interactive_ftui.rs).
Interactive queued input. In the default terminal interface, messages accepted as a turn finishes continue in their original order, with each message's prepared file contents preserved. They keep separate message boundaries and their own authored instructions. Ordinary steering and follow-up input can include images and audio/video. Aborts, failures, and run-time caps preserve unclaimed prepared input for review, including captured attachment bytes. Resubmitting an unchanged recovered draft reuses those bytes.
ACP transport limits. Input JSON frames are capped at 128 MiB before parsing, excluding the final LF. At most two unread frames are queued; backpressure preserves their order. An oversized frame, invalid UTF-8, or stdin read failure produces a JSON-RPC parse error with a null ID and closes input admission. Active prompts follow the normal cancellation, persistence, and cleanup path before exit. Ordinary malformed JSON remains recoverable, and a bounded final frame without LF is accepted at EOF. Attachment limits below still apply independently.
ACP workspace settings. Sessions created by pi --acp resolve global
settings and trusted settings from the requested workspace when creating,
loading from disk, or forking a session. Reattaching to a running session keeps
its admitted settings, including prompt, steering, and media policy. Launching
with --trust does not approve unrelated workspaces requested later by the
editor. Explicit CLI choices keep precedence. See
ACP workspace settings for trust and
configuration-path details.
ACP model selection. After initialize, session/new, session/load, and
session/resume return model choices and the active selection. Modern clients
use the model selector in configOptions and send
session/set_config_option with configId: "model". Older clients can use
models.currentModelId, models.availableModels, and session/set_model with
modelId. Both surfaces use the same opaque provider/model values, including
custom BYO IDs containing slashes or query strings. Successful selections
publish a complete config_option_update before the response, including any
change to the model's supported thinking level.
Choices come from Pi's existing model registry and credential availability,
with the requested workspace's disabled-provider policy applied. --models
and enabled_models guide startup and cycling; explicit editor selections can
choose other registered models. The current model stays visible when restoring
a saved session or making an explicit selection outside those preferences.
An explicit --api-key admits additional models only for its bound provider;
other providers still need their own credentials unless they require no key.
If an editor shows an empty picker, compare its session/new response with
pi --list-models using the same configuration and launch environment.
ACP planning. The editor's Session Mode selector offers code and plan
through the mode entry in configOptions. Older ACP v1 clients can use
modes and session/set_mode. Plan mode allows exploration while blocking
mutating tools and process execution. When the agent submits a plan, Pi asks
the editor to review its full text. Approving that exact proposal switches to
Code and continues the conversation; implementation tools still require their
ordinary editor permissions. Rejecting keeps the session in Plan mode.
Cancelled, unknown, or stale permission responses cannot approve a plan.
Changing mode during a prompt cancels that prompt and waits for its session cleanup before acknowledging the selection. Saved or forked submitted plans restore for fresh review, never with inherited execution approval. Planning controls are unavailable when built-in tools are disabled.
ACP clarification questions. Editors can enable native ask by advertising
clientCapabilities.elicitation.form: {} during initialization. When the host
enables that tool, Pi presents questions through elicitation/create in both
Code and Plan modes. Forms support single or multiple selections and an Other
answer; accepted answers return through the ordinary native tool result.
The editor's tool permission prompt still precedes the question, and answering
does not approve a submitted plan or grant permission to write files.
Declined, dismissed, malformed, or expired forms never choose a recommendation
automatically. Session cancellation, live steering, and disconnects retire the
owning request, so a late response cannot answer another question. Forms time
out after five minutes and are for implementation decisions, not credentials
or authentication. Clients without explicit form support do not receive the
ask tool, and --no-tools remains authoritative.
ACP context maintenance. The editor's command menu includes /compact [focus], /compact aggressive [focus], /shake [focus], and /handoff [focus]. These invoke the native context transactions without creating a user
message or an ordinary assistant turn. Compaction summarizes older context;
aggressive compaction retains a smaller recent window. Shake drops bulky older
tool output without requesting a model summary. Handoff saves a continuation
brief in the same session using its current model. Recent complete turns and
tool-call/result pairs retain the native preservation rules.
Send a context command as one standalone text block. Additional text blocks,
attachments, and embedded resources cannot become command arguments. Native
command names take precedence over extension registrations. session/cancel
can stop preparation; a save already in progress settles before the command
returns, and success is reported only after durable installation. An editor
can send another prompt after completion using the updated context. Handoff
preview, report, export, and import options remain available through their
existing terminal and SDK surfaces, rather than these editor commands.
ACP session forks. Pi advertises the optional ACP v1 draft
sessionCapabilities.fork capability. A client can create an active branch
from the source's complete selected conversation:
{"jsonrpc":"2.0","id":7,"method":"session/fork","params":{"sessionId":"SOURCE_ID","cwd":"/absolute/workspace","mcpServers":[]}}
The response contains a new sessionId, model choices, and configOptions.
The last user message and assistant reply are included in the fork; the source
keeps its conversation and remains usable. Forking does not run the model or
replay the transcript. Use session/load on the returned ID when an editor
needs the inherited history. A live source or an exact saved ID in the configured
session directory can be forked. With --session-dir, the fork is saved before
success is acknowledged, including retained model spend and pending billing
ancestry. Live source and fork share the configured session-tree cost budget.
Forks stay in the source's canonical workspace; nonempty
additionalDirectories are rejected. The request supplies a fresh MCP server
list (omission means none), and editor file requests, terminal requests, and
permissions use the new session identity. An active source prompt, unresolved
editor write, unsettled terminal cleanup, or failed-persistence admission fence
blocks the fork until the source is ready.
ACP attachments. session/prompt accepts ordered text, images, native
audio blocks, and embedded audio/video resource blobs. Audio-only prompts
work. Gemini-family providers receive native media; other transports show an
explicit omission label while the complete attachment stays in session history
and editor replay. Audio/video admission honors media.maxBytes (64 MiB by
default), with a 10 MiB transport ceiling per attachment and at most 32 media
attachments per prompt. See ACP audio and video prompts
for the editor wire format and aggregate limits.
ACP live steering. The initialize response advertises
_meta.steering.supported: true. Editors can send _session/steering with
sessionId and the same prompt content blocks as session/prompt while a
turn is running. Text, images, audio/video, and embedded references retain
their native form and the same media limits. Set _meta.steering.queue to
"followUp" to request delivery after the current model turn; the default
"steering" lane delivers at the next native
steering boundary. Steering cancels that session's open permission dialog via
$/cancel_request; a follow-up leaves the dialog open.
The response is {"outcome":"injected","queue":"steering"} (or
"followUp") when the native agent claims the input. This acknowledges
handoff, not completed execution or durable storage. Idle input, and input
still unclaimed when its owning turn ends or is cancelled, returns
"promptRequired" so the editor can submit it as a new session/prompt.
Unclaimed responses follow the original prompt's terminal response and cleanup;
unclaimed input is never carried into a different prompt. The per-turn queue
holds at most 100 requests and 8 MiB; each request is limited to 128 blocks,
4 MiB for serialized content and request ID together, and 256 KiB of authored prose.
An overflowing queue returns "failed" without accepting the input.
ACP editor files. Clients can advertise clientCapabilities.fs.readTextFile
and writeTextFile in initialize. Pi then sends standard outbound
fs/read_text_file and fs/write_text_file requests, scoped to the owning
sessionId and an absolute workspace path. Native read, write, edit, and
hashline_edit work with unsaved editor buffers, including new files that do
not yet exist on disk. Tool approval and workspace/symlink checks run before
any editor request. Text buffers are limited to 10 MiB; read pagination and
hashline tags are derived from the editor text. Rendered documents, notebooks,
binary media, internal artifacts, and non-file URLs keep their native routes.
Capabilities are independent: without an advertised capability the corresponding operation remains local. A failed advertised editor read never falls back to stale disk content. With a read-only client, an edit can write locally only if disk still matches the exact editor preimage. Edits re-read their source before writing to catch intervening changes; ACP does not provide atomic versioned compare-and-swap. After an acknowledged editor write, Pi reads back when possible and reports formatter changes from the resulting buffer. If read-back is unavailable, Pi reports an acknowledged, unverified write and does not claim a verified diff or a disk undo record.
Cancellation discards pending reads and ignores their late responses. A write already published to the editor may still complete: cancellation or timeout stops the current prompt and holds further prompts or reloads for that session until its matching valid acknowledgment or error arrives. Pi explicitly reports that the write was not rolled back. Malformed or unrelated responses cannot clear this hold, and other sessions can continue normally.
Interactive mode provides the full experience: a multi-line text editor with history, scrollable conversation viewport, model selector (Ctrl+L), scoped model cycling (Ctrl+P/Ctrl+Shift+P), session branch navigator (/tree), and real-time token/cost tracking. Since v0.4.0 the default interactive stack is the FrankenTUI (ftui) runtime; pi --inline keeps your shell scrollback by drawing the UI at the bottom of the screen instead of on the alternate screen, and pi --classic (aliases --classic-tui, --charmed, --bubbletea) selects the previous charmed_rust stack until it is removed.
Browser companion (pi web) keeps the normal FrankenTUI session running and
offers a private, one-time pairing link for a browser on the same computer.
The browser shows screened completed messages and can propose a prompt for
explicit F8 acceptance on the local terminal. Drafts, tool approvals, login,
and cancellation stay in the terminal. Use /web for pairing or inbox review
and /web revoke to close browser access. See the
browser companion guide for options and limits.
Browser terminal mirror (pi web --terminal) projects the native terminal
through bounded WebSocket keyframes and patches. The local F8 panel issues
one-use links and grants or revokes remote control. Host input reclaims control;
the remote composer preserves local drafts and cannot operate local approval,
credential, or extension dialogs. Complete sources are screened before clipping,
and local drafts, in-flight response text, and truncated tool cards stay local.
Headless and WASM operation remain unimplemented.
Print mode sends one or more messages, streams each response to stdout, and exits. Useful for shell scripts and one-off queries.
Text and JSON print modes use the same success contract: a terminal provider
failure or cancellation exits 1 and stops before any remaining prompt.
Retries and configured failover finish before Pi decides the final outcome.
JSON output retains the completed agent lifecycle, followed by one
{"type":"error","phase":"run",...,"exit_code":1} diagnostic. Missing or
whitespace-only input is a usage error (2); JSON mode reports it before
opening a session stream. Headless denied tool approvals exit 3, configured
or explicit resource load failures (--skill, --prompt-template,
--theme-path) exit 4, and reaching a session cost cap (maxCost) exits
5. A successfully recovered request still exits 0.
Print mode and tool approval. The approval mode defaults to always-ask on
every surface, including -p. The absence of a terminal is not treated as
consent, so Pi does not quietly auto-approve a scripted run. Print mode also has
no way to prompt, which means a gated tool call in a default -p run is denied.
Pass --approval-mode yolo (or --yolo) to auto-approve tool calls, or set
approval.mode in settings.json:
echo "list the files here" | pi -p --mode json --yolo
When a run does end with tool calls denied for want of an approval surface, Pi
exits 3 and explains why on stderr, rather than exiting 0 on a turn that
silently did nothing. In --mode json and --mode rpc the same failure also
arrives as the single machine-readable record described under --mode, with
"code": "approval.surface_unavailable". Exit 3 means specifically "the model
could not use tools"; exit 1 remains an ordinary failure and exit 2 a usage
error.
This is a deliberate divergence from the Node Pi CLI, which auto-approves in
print mode. Legacy Pi is historical context here, not a compatibility
authority, and inheriting its default would silently grant bash and write
access to any script that never opted in.
RPC mode exposes a line-delimited JSON protocol for programmatic control. Clients send commands (prompt, steer, follow-up, abort, get-state, compact) and receive streaming events. This is how IDE extensions and custom frontends integrate with Pi. See RPC Protocol for the wire format.
Pi supports two extension runtime families with capability-gated host connectors:
JS/TS entrypoints run without Node or Bun in an embedded QuickJS runtime.
*.native.json descriptors run in the native-rust descriptor runtime.
Extension entrypoints are auto-detected:
.js/.ts/.mjs/.cjs/.tsx/.mts/.cts run directly in embedded QuickJS (no descriptor conversion).*.native.json loads the native-rust descriptor runtime.Cold/warm extension load paths are instrumented; fresh comparative measurements are pending
Node API shims for fs, path, os, crypto, child_process, url, and more
Capability-based security: extensions call explicit connectors (tool/exec/http/session/ui) with audit logging
Command-level exec mediation: dangerous shell signatures are classified and blocked before spawn, with redacted denial alerts and mediation ledger entries
Trust-state lifecycle and kill-switch controls with audited state transitions (pending/acknowledged/trusted/killed)
Workspace trust-on-first-use gate: project settings, extension files, MCP configuration, and discovered project agent profiles require approval keyed to workspace path and content digest. --trust, PI_WORKSPACE_TRUST, or global trustAllWorkspaces support automation; non-interactive launches fail closed.
Opt-in hostcall reactor mesh telemetry (enable_hostcall_reactor) with shard routing and bounded queue backpressure tracking (production defaults use direct inline fast/compat lane dispatch without extra queue cloning)
Fresh owner-isolated realms on every reload, with versioned persistent transpile caching instead of mutable realm reuse
Imported createReadTool, createWriteTool, createEditTool, createBashTool,
createGrepTool, createFindTool, and createLsTool factories execute the host's
enabled native tools, including when an extension wraps the same tool name.
They preserve file undo recording, capability checks, workspace boundaries,
cancellation, and progress callbacks. Supported factory settings and limitations
are listed in the extension compatibility matrix.
/model (or Ctrl+L) opens a selector focused on models that are ready to run with current credentials.Ctrl+P and Ctrl+Shift+P cycle through the scoped model set without opening the overlay./login.Extensions can register tools, slash commands, event hooks, flags, providers, and shortcuts. See EXTENSIONS.md for the full architecture and docs/extension-catalog.json for the 223-entry catalog with per-extension conformance status and perf budgets.
This project validates extension compatibility with a three-track pipeline:
target/release/pi execution against a non-mocked provider/model path.Fetch unvendored source corpus
ext_unvendored_fetch_run.tmp-codex-unvendored-cache/tests/ext_conformance/reports/pipeline/unvendored_fetch_probe_report.jsontests/ext_conformance/reports/pipeline/unvendored_fetch_probe_events.jsonlRun end-to-end validation orchestration
ext_full_validationrefresh_onboarding_queue (runs ext_onboarding_queue)conformance_shard_0..N (runs ext_conformance_generated sharded matrix)conformance_failure_dossiersprovider_compat_matrixscenario_conformance_suiteauto_repair_full_corpusdifferential_suite (optional, enabled via --run-diff; npm diff via --run-npm-diff)tests/ext_conformance/reports/pipeline/full_validation_report.jsontests/ext_conformance/reports/pipeline/full_validation_report.mdtests/ext_conformance/reports/**Run dev-firstset live-provider gate (must pass before release build)
ext_release_binary_e2epass=20 / total=20 with fail=0.tests/ext_conformance/reports/release_binary_e2e/ollama_firstset_dev_20260219_jobs10_timeout600.jsontests/ext_conformance/reports/release_binary_e2e/ollama_firstset_dev_20260219_jobs10_timeout600.mdRun full release-binary live-provider E2E (after step 3 passes)
ext_release_binary_e2etarget/release/pi directly for each selected extension case.ollama + qwen2.5:0.5b) to exercise non-mocked end-to-end behavior.pi.ext.release_binary_e2e.v1).tests/ext_conformance/reports/release_binary_e2e/ollama_full_release_20260219_jobs10_timeout600.jsontests/ext_conformance/reports/release_binary_e2e/ollama_full_release_20260219_jobs10_timeout600.mdtests/ext_conformance/reports/release_binary_e2e/cases/*Aggregate and triage
full_validation_report.json combines:
stageSummary, stageResults)corpus)conformance)providerCompat)scenario)reviewQueue, verdictCounts)not_tested_unvendored indicates unvendored candidates not yet in vendored conformance; this is inventory status, not a vendored regression.These runs compile many crates and can be disk-heavy. DSR owns target/temp placement, load admission, and any remote offload. Run the registered recipe:
dsr quality --tool pi_agent_rust
These artifacts predate v0.3.0 and do not certify the current source revision.
The strict drop-in program has been retired; its contract and verdict are no
longer release gates and will not be rerun to define product completeness. The
figures below are retained only as a dated engineering snapshot.
The current extension must-pass corpus is the exact set selected by
docs/extension-inclusion-list.json; the historical counts below do not prove
coverage of that authoritative list.
From:
tests/ext_conformance/reports/gate/must_pass_gate_verdict.json (generated 2026-11-25T09:25:51.681Z, run local-20261125T092551681Z)
tests/ext_conformance/reports/health_delta/health_delta_report.json (generated 2026-11-25T07:27:38.391Z)
tests/ext_conformance/reports/journeys/journey_report.json (generated 2026-09-23T03:58:34.679Z)
tests/evidence_bundle/index.json (generated 2026-11-21T05:50:57.069503Z, run local-bundle-fix-20261121T055057Z)
tests/full_suite_gate/certification_verdict.json (generated 2026-11-25T07:24:53.579Z)
Historical verdict blob at 2fc4b8c0b77ded267cf5e0f517f4b6fa87f45e91:docs/evidence/dropin-certification-verdict.json (generated 2026-05-18T19:37:26Z for source 52e9fbfb24352045985b59df9d7ea63f1f8f2ef8; the live file may contain a later verdict)
Historical strict drop-in result: 22/22 certification gates PASS, 16/16 blocking gates PASS - CERTIFIED for source 52e9fbfb24352045985b59df9d7ea63f1f8f2ef8 only (from the Git-pinned historical verdict blob above; it neither describes the live verdict file nor certifies v0.3.0)
Unified evidence bundle, as regenerated 2026-11-21: 30 total sections, 18 present, 12 missing, 0 invalid (bundle verdict: partial) (from tests/evidence_bundle/index.json; historical snapshot)
Extension must-pass gate, as regenerated 2026-11-25: 208/208 must-pass extensions passed (0 failures); informational stretch set 17/19 passed — the May 2026 123/123 snapshot predates the expanded corpus (from tests/ext_conformance/reports/gate/must_pass_gate_verdict.json; historical snapshot)
Extension health delta, as regenerated 2026-11-25: 226 extensions tested at 99.6% pass rate (225/226) with 0 regressions vs the 2026-02-07 baseline (from tests/ext_conformance/reports/health_delta/health_delta_report.json; historical snapshot)
Extension journey coverage, as regenerated 2026-09-23: 125/125 journey scenarios passed (100.0%); command, event-subscriber, multi-capability, passive, and tool-provider categories are green (from tests/ext_conformance/reports/journeys/journey_report.json; historical snapshot)
Historical stress-triage evidence is retained under tests/perf/reports/; it is not current enough to support a release-facing performance claim.
As of November 21, 2026, the latest published stable release is v0.9.0. It is
the first release that includes /goal; see the
goal guide. Fetching the installer from main
still selects a published release binary, so it does not install features added to
main after that release. Check the full pi --version output, including its
commit hash, when comparing an installation with the current documentation.
Use the current installer with --version to pin the binary. Installer fixes
ship separately from binary releases: pinning an older binary such as v0.8.0 with
the current installer keeps the fixes for stock macOS tar/xz support and older awk
versions that are absent from the installer at the v0.8.0 tag.
The current installer requires the Minisign CLI for official release binaries.
Install it with brew install minisign on macOS or sudo apt install minisign on
Debian/Ubuntu. It verifies both the artifact's .minisig and the signed
SHA256SUMS manifest with the public key pinned in this repository's
minisign.pub, before extracting or running the downloaded binary.
The authenticated metadata must match the requested project, release, platform,
filename, and digest. Missing or invalid signatures stop installation; a checksum
override does not bypass this requirement for official release URLs.
Use versioned /releases/download/<tag>/<asset> URLs for explicit official
artifacts; the unversioned /releases/latest/download/ alias is rejected. Old
releases without the required signatures are also rejected. Custom and offline
artifacts retain caller-supplied checksum verification; use --minisign-url to
require a detached signature for those artifacts too. The signature must use the
same pinned project key.
The native pi self-update implementation on main verifies signatures internally
and does not require the Minisign CLI. It authenticates the manifest and raw binary
before replacement, and automatic latest-version updates cannot downgrade an
installed version. An explicit --version still permits an intentional older
signed release.
# Latest release
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | bash
# Non-interactive + auto PATH update
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | bash -s -- --yes --easy-mode
# Pin the binary release while using the current installer
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | bash -s -- --version v0.9.0
# Install the Linux x86-64 artifact with its published checksum
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | \
bash -s -- \
--version v0.9.0 \
--artifact-url "https://github.com/Dicklesworthstone/pi_agent_rust/releases/download/v0.9.0/pi-linux-amd64.tar.xz" \
--checksum-url "https://github.com/Dicklesworthstone/pi_agent_rust/releases/download/v0.9.0/pi-linux-amd64.tar.xz.sha256"
# Skip completion setup (CI/non-interactive minimal install)
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh?$(date +%s)" | \
bash -s -- --yes --no-completions
The installer is idempotent and supports a migration path from TypeScript Pi:
pi commandpilegacy-piNotable installer flags:
--offline [TARBALL]: enforce offline mode; optional local artifact path (.tar.gz, .tar.xz, .zip, or raw binary)--artifact-url: force a specific release artifact URL--checksum / --checksum-url: override checksum source for explicit artifacts--minisign-url: supply a required detached Minisign signature for a custom or offline artifact, verified with the pinned project key--sigstore-bundle-url: override the optional Sigstore bundle URL used by
cosign verify-blob; set both COSIGN_IDENTITY_RE and
COSIGN_OIDC_ISSUER to the trusted signer policy (there is deliberately no
GitHub Actions identity default)--completions auto|off|bash|zsh|fish: force shell completion install target (off is equivalent to --no-completions)--no-completions: disable completion installation--no-agent-skills: skip automatic installation of the pi-agent-rust skill into ~/.claude/skills/ and ~/.codex/skills/--no-verify: skip checksum + signature verification (testing only)--artifact-url without --version uses a synthetic tag for release mode only; if artifact download fails, install exits instead of attempting source fallbackHTTPS_PROXY / HTTP_PROXY for all network fetchesBy default, the installer also installs a pi-agent-rust skill for both Claude Code and Codex CLI:
~/.claude/skills/pi-agent-rust/SKILL.md~/.codex/skills/pi-agent-rust/SKILL.md (or $CODEX_HOME/skills/pi-agent-rust/SKILL.md if CODEX_HOME is set)Installer regression harness (options + checksum + signature + completions):
bash tests/installer_regression.sh
For migration adoption, packaging and invocation compatibility follows this contract:
This section covers packaging and invocation behavior only. Historical drop-in/parity artifacts do not define the current product or release gate. Current compatibility statements must name the concrete behavior they cover.
Canonical executable name is pi across release assets and installer-managed installs.
Installer-managed installs also create an rpi compatibility launcher when no conflicting rpi command already exists on your PATH.
Existing TypeScript pi installs can be migrated in place; the prior command is preserved as legacy-pi.
If you keep TypeScript pi as canonical (--keep-existing-pi), Rust Pi is installed as pi-rust.
On Apple Silicon, the installer prefers the native arm64 artifact even when launched from a Rosetta-translated shell.
Version-pinned installs are supported via install.sh --version vX.Y.Z for deterministic rollouts.
DSR releases ship each platform archive with a same-name .sha256 sidecar
for integrity validation. The v0.3.0 release predates that contract and
ships an aggregate SHA256SUMS instead; the installer verifies the
per-asset sidecar first and falls back to SHA256SUMS only when the
sidecar is absent.
Representative smoke checks:
# Canonical command should exist and execute
command -v pi
pi --version
pi --help >/dev/null
# If a TS migration was performed, legacy command remains available
command -v legacy-pi && legacy-pi --version
Repository builds are tested with the exact toolchain pinned in
rust-toolchain.toml (nightly-2026-08-31). The locked dependency graph
requires Rust 1.97 or newer. Project builds are DSR-only:
dsr quality --tool pi_agent_rust
dsr build pi_agent_rust
End users should install a DSR-published archive through install.sh. There is
no supported direct-Cargo contributor or installation lane.
Pi has no required external runtime dependencies: the grep and find
tools search in-process using the same engines ripgrep is built from
(grep-searcher/grep-regex and the ignore walker), so patterns keep
ripgrep's default (Rust regex crate) syntax. PCRE2-only features
(lookaround, backreferences) were never exposed and remain unsupported.
To shell out to rg/fd instead (debugging escape hatch), set
"search_backend": "external" in settings.json and install them via
apt install ripgrep fd-find or brew install ripgrep fd.
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/uninstall.sh" | bash
By default, uninstall removes installer-managed Rust binaries/aliases and skill directories,
then restores a migrated TypeScript pi if one was preserved.
pi [OPTIONS] [MESSAGE]...
# Examples
pi # Start interactive session
pi "Hello" # Start with message
pi @file.rs "Explain this" # Include file as context
pi @voice.wav @clip.mp4 "Compare these recordings"
pi -p "Quick question" # Print mode (no session)
Interactive file references:
@relative/path in the editor to attach a file’s contents (autocomplete inserts the @ form)..mp4, .mov, .webm, .mp3, .wav, .flac, .ogg, and .m4a (case-insensitive), with a 64 MiB per-file limit (media.maxBytes). Oversized files produce a visible notice and empty files are skipped.--add-dir or /add-dir; /remove-dir revokes subsequent attachment reads. CLI startup files and messages are submitted by both terminal frontends, and FTUI /retry retains the original attachment bytes.| Option | Description |
|---|---|
-c, --continue | Continue most recent session |
-r, --resume | Open session picker UI |
--session <PATH> | Open specific session file |
--session-dir <DIR> | Override session storage directory for this run |
| `--session-durability strict | balanced |
--no-session | Don't persist conversation |
-p, --print | Single response, no interaction |
| `--mode text | json |
--provider <NAME> | Force provider for this run (aliases supported) |
--model <MODEL> | Model to use (auto-select fallback: openai-codex/gpt-5.6-sol, then openai/gpt-5.6, then anthropic/claude-sonnet-4-6) |
--thinking <LEVEL> | Thinking level: off/minimal/low/medium/high/xhigh/max |
--tools <TOOLS> | Comma-separated tool list; overrides optional-tool activation settings for this run. An empty list disables all built-ins |
--no-tools | Disable built-in tools, including tools enabled in settings |
--api-key <KEY> | API key (or use provider-specific env vars such as ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) |
| `--extension-policy safe | balanced |
| `--repair-policy off | suggest |
--list-models [PATTERN] | List available models (optional fuzzy filter) |
--list-providers | List canonical provider IDs, aliases, and auth env keys |
--fetch-models <PROVIDER> | Print provider model IDs to stdout and exit; warns when using the static fallback |
--refresh-models | With --fetch-models, bypass the same-process cache and require a successful live response |
--persist-models | With --fetch-models, atomically save a verified live/same-process-cache catalog for future model pickers |
--export <PATH> | Export session file to HTML |
Additional high-leverage flags:
--no-migrations to skip startup migration checks--explain-extension-policy to print effective capability decisions and exit--explain-repair-policy to print effective repair-policy resolution and exit# Package management
pi install <source> [-l|--local] # Install a package source and add to settings
pi remove <source> [-l|--local] # Remove a package source from settings
pi update [source] # Update all (or one) non-pinned packages
pi list # List user + project packages from settings
# Configuration
pi config # Show settings paths + precedence
# Supervised browser companion (F8 reviews each prompt)
pi web
# Native terminal mirror (F8 grants/revokes browser control)
pi web --terminal --bind tailscale --view-only --port 9000
More utility subcommands:
# Extension catalog index + discovery
pi update-index
pi search "git"
pi info pi-search-agent
# Environment and extension diagnostics
pi doctor
pi doctor --only sessions --format json
pi doctor --only swarm --format json
pi doctor ./path/to/extension --policy safe --fix
# Session recovery, import, handoff, garbage collection, and migration
pi import --from-claude ~/.claude/projects/...
pi recover <session-or-crash-bundle>
pi handoff --to "next agent" --print
pi gc --older-than 30d --dry-run
pi migrate ~/.pi/agent/sessions --dry-run
pi migrate ~/.pi/agent/sessions
# Git workflow, code review, worktrees, and policy rules
pi review staged --offline
pi commit --dry-run
pi worktree list
pi rules list
pi grievances list
# Usage, spend stats, profiling, token counting, UI gallery, and self-update
pi stats --format json
pi usage --format json
pi token ./src/main.rs
pi profile --top 20
pi gallery --format text
pi completions bash
pi self-update --check
# Read-only swarm, context-pack, replay, and validation-broker inspection
pi context-preview --format json
pi swarm-progress --input progress-slo-input.json --format json
pi swarm-replay-preview --trace trace.jsonl --format json
pi validation-broker status --store slots.jsonl --format json
update-index, search, and info refresh and query extension catalog metadata without leaving the CLI.pi doctor checks ordinary installation health: config, directories, auth, shell setup, and sessions. Swarm coordination diagnostics are opt-in with --only swarm (or a comma-separated selection including swarm); they require development infrastructure such as Beads, Agent Mail, RCH, and build scratch space. pi doctor --only swarm --format json reports cgroup CPU quota, cpuset size, NUMA topology, cgroup memory limits, target/tmp headroom, and recommended concurrency budgets before large multi-agent runs. These explicit checks remain strict and fail closed on operational hazards. Text, JSON, and markdown reports use the same selected findings and exit with status 1 when any selected check fails; warnings and informational findings exit 0. Supplying an extension path checks extension compatibility by default.import, recover, handoff, gc, and migrate manage session lifecycle: importing Claude/Codex transcripts, recovering crashed or corrupted sessions, generating structured session handoffs, pruning old sessions/caches, and migrating JSONL sessions to the v2 segment sidecar format.review, commit, worktree, rules, and grievances support repository review, commit staging, isolated git worktrees, project stream-abort rules, and logged agent grievances.stats, usage, token, profile, gallery, completions, and self-update provide local cost/token analytics, provider quota checks, BPE token counting, turn/tool profiling, UI component previews, shell completion scripts (backed by the hidden __complete helper), and verified release updates.context-preview, swarm-progress, swarm-replay-preview, and validation-broker provide read-only swarm/context diagnostics and SLO evaluation without mutating Beads, git, Agent Mail, RCH, or source files. Operator workflow, privacy boundaries, degraded Agent Mail/RCH interpretation, stale-Beads handling, and no-open-work convergence guidance lives in docs/swarm-operations-runbook.md#progress-slo-operator-workflow.Pi reads configuration from ~/.pi/agent/settings.json. Keys are shown in
their canonical snake_case form below, but every field also accepts the
original TypeScript Pi's camelCase spelling (e.g. defaultProvider,
shellCommandPrefix) as a serde alias, so an existing pi-mono settings.json
is parsed as-is and is never rewritten to snake_case:
{
"default_provider": "anthropic",
"default_model": "claude-opus-4-5",
"default_thinking_level": "medium",
"compaction": {
"enabled": true,
"reserve_tokens": 8192,
"keep_recent_tokens": 20000,
"thresholdPercent": 75,
"methodOrder": ["shake", "soft"]
},
"retry": {
"enabled": true,
"max_retries": 3,
"base_delay_ms": 1000,
"max_delay_ms": 30000
},
"images": {
"auto_resize": true,
"block_images": false
},
"terminal": {
"show_images": true,
"clear_on_shrink": false
},
"http": {
"proxy": "http://127.0.0.1:2080",
"no_proxy": ["localhost", "127.0.0.1", ".internal.example"]
},
"shell_path": "/bin/bash",
"shell_command_prefix": "set -e"
}
Every request Pi makes — provider APIs, OAuth logins, update checks, URL reads,
package fetches — goes through the proxy resolved here. https:// targets use a
CONNECT tunnel, so TLS stays end-to-end to the origin and the proxy never sees
plaintext; http:// targets use an absolute-form request line. Credentials in
the proxy URL (http://user:pass@host:port) become Proxy-Authorization, and
are never logged or passed to child processes.
Resolution order for a request, first match wins:
http.no_proxy in settings.json, else NO_PROXY /
no_proxy. Entries follow the usual convention: * bypasses everything,
example.com or .example.com matches the domain and its subdomains, and
example.com:8443 restricts the match to that port. Loopback destinations
also bypass the proxy by default, unless http.proxyLoopback is enabled.http.https_proxy / http.http_proxy (scheme-specific settings).http.proxy (both schemes).PI_HTTPS_PROXY / PI_HTTP_PROXY.HTTPS_PROXY, HTTP_PROXY, ALL_PROXY (lowercase spellings
accepted).Ambient proxy variables are honored by default, the same as git and curl.
Where they are set for some other tool — a capture proxy, a stale VPN helper —
turn the inheritance off with "http": { "ignore_env_proxy": true } or
PI_HTTP_PROXY=off; explicit settings and PI_*_PROXY still apply. Proxy
endpoints may be http://, https://, socks5:// (local DNS) or socks5h://
(DNS on the proxy), with optional username/password authentication. An
https:// proxy encrypts and authenticates the hop to the proxy before sending
credentials or CONNECT metadata. HTTPS destinations receive an independent
TLS connection inside that tunnel; both peer certificates and hostnames must
verify against Pi's configured trust store. A failed handshake or refused
CONNECT never falls back to plaintext or a direct connection. HTTP and SOCKS
proxy credentials are not encrypted on the hop to the proxy.
Requests to localhost (case-insensitive,
with an optional trailing dot), literal IPv4 addresses in 127.0.0.0/8, and
IPv6 ::1 or IPv4-mapped loopback addresses go directly to the local server.
This keeps Ollama and LM Studio reachable when a global proxy is configured.
Pi makes this decision without DNS lookups; private-network addresses and other
hostnames retain the configured proxy routing.
To intentionally send loopback destinations through the proxy, such as to reach
a service on the proxy host or capture local traffic, set
"http": { "proxyLoopback": true }. Explicit NO_PROXY / http.noProxy
matches still take precedence. An unusable ambient value (e.g. a socks4://
endpoint) is skipped with a warning rather than failing requests.
The bash tool's child environment overrides advertise only HTTP(S) proxy
endpoints (as HTTP_PROXY/HTTPS_PROXY/NO_PROXY and their lowercase
spellings). Credentials are deliberately omitted from that per-child copy,
so authenticated HTTP proxies need their own configuration in those tools
(e.g. git config --global http.proxy). Pi's own environment and the system
environment are never modified. SOCKS endpoints leave child proxy variables
as inherited, including authenticated ALL_PROXY values and NO_PROXY.
This preserves existing curl/git SOCKS configuration without forcing tools
that lack SOCKS support to use it through HTTP-specific variables. A SOCKS
proxy set only in Pi settings or PI_*_PROXY does not configure child tools;
use their standard proxy environment variables or their own configuration.
The automatic loopback bypass applies to Pi's own HTTP requests; child tools
continue to follow their own proxy and bypass configuration.
Settings are resolved in priority order (first match wins):
--model, --thinking, --provider, etc.)ANTHROPIC_API_KEY, PI_CONFIG_PATH, etc.).pi/settings.json in the working directory)~/.pi/agent/settings.json)This means a CLI flag always overrides a settings.json value, and a trusted
project-level setting overrides the global one. Untrusted project settings are
excluded. Optional-tool activation flags merge individually; a project can set
one flag to false while inheriting the other global flags.
Resource resolution gives explicit CLI paths priority, followed by CLI -e
sources, configured project resources, configured user resources, and installed
packages. Project packages take priority over user packages.
Skills additionally discover universal .agents/skills/ directories from the
working directory through its ancestors up to the Git root (or filesystem root
when no Git root exists), plus ~/.agents/skills/ in the user's home directory.
Ancestor probing is capped at 64 locations and each selected skill root has a
16,384-entry discovery budget; an over-budget root is rejected rather than
partially loaded. Within each scope, Pi-specific skills and settings entries take
priority over universal skills; nearer project universal roots take priority over
farther ancestors, and project universal skills still take priority over user
skills. Managed
skills from <agent_dir>/skills.managed/ load last. See the complete
skill precedence table.
When multiple resources share the same name, the first occurrence wins. Collisions are logged as diagnostics.
--no-skills disables automatic discovery (including universal and managed
skills), installed package skills, and skills entries in settings.json.
Explicit CLI --skill paths and skills supplied by CLI -e sources still load,
so pi --no-skills --skill /path/to/skill-a --skill /path/to/skill-b selects an
isolated skill set. The sibling --no-prompt-templates, --no-themes, and
--no-extensions flags likewise preserve explicit CLI resources while disabling
configured discovery for their categories.
Project context files are a separate switch. By default pi appends AGENTS.md / CLAUDE.md from ~/.pi/agent/, the working directory, and every ancestor directory to the system prompt (plus imported foreign-format workspace rules). --no-context-files (or PI_NO_CONTEXT_FILES=1) disables that discovery entirely; --no-skills does not cover it. Hosts that compose the whole prompt with --system-prompt typically pass --no-context-files --no-skills together.
Prompt template expansion supports positional arguments: $1, $2, $@ (all args), and slice syntax ${@:start}, ${@:start:length} (or OMP's $@[start:length]). For example, a template invoked as /review src/main.rs --strict receives src/main.rs as $1 and --strict as $2. A template with no placeholder gets its arguments appended after a blank line.
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Anthropic API key |
OPENAI_API_KEY | OpenAI API key |
GOOGLE_API_KEY | Google Gemini API key |
AZURE_OPENAI_API_KEY | Azure OpenAI API key |
COHERE_API_KEY | Cohere API key |
GROQ_API_KEY | Groq API key (OpenAI-compatible) |
DEEPINFRA_API_KEY | DeepInfra API key (OpenAI-compatible) |
CEREBRAS_API_KEY | Cerebras API key (OpenAI-compatible) |
OPENROUTER_API_KEY | OpenRouter API key (OpenAI-compatible) |
ORCAROUTER_API_KEY | OrcaRouter API key (OpenAI-compatible) |
MISTRAL_API_KEY | Mistral API key (OpenAI-compatible) |
MOONSHOT_API_KEY | Moonshot/Kimi API key (OpenAI-compatible) |
DASHSCOPE_API_KEY | DashScope/Qwen API key (OpenAI-compatible) |
DEEPSEEK_API_KEY | DeepSeek API key (OpenAI-compatible) |
FIREWORKS_API_KEY | Fireworks API key (OpenAI-compatible) |
TOGETHER_API_KEY | Together API key (OpenAI-compatible) |
PERPLEXITY_API_KEY | Perplexity API key (OpenAI-compatible) |
XAI_API_KEY | xAI API key (OpenAI-compatible) |
PI_CONFIG_PATH | Custom config file path |
PI_CODING_AGENT_DIR | Override the global config directory |
PI_SUBAGENT_PI_BINARY | Explicit Rust Pi executable for native child agents; defaults to the current executable |
PI_JOBS_ARTIFACT_RETENTION | Background-job artifact policy: rotate (default, deletes the oldest unlocked logs when the budget is full) or preserve (keeps every log, refuses new jobs when full) |
PI_PACKAGE_DIR | Override the packages directory |
PI_SESSIONS_DIR | Custom sessions directory |
┌─────────────────────────────────────────────────────────────────┐
│ CLI (clap) │
│ • Argument parsing • @file expansion • Subcommands │
└─────────────────────────────────┬───────────────────────────────┘
│
┌─────────────────────────────────▼───────────────────────────────┐
│ Agent Loop │
│ • Message history • Tool iteration • Event callbacks │
└────────┬──────────────────────┬──────────────────────┬──────────┘
│ │ │
┌────────▼────────┐ ┌─────────▼──────────┐ ┌───────▼──────────┐
│ Provider Layer │ │ Tool Registry │ │ Extension Mgr │
│ • Anthropic │ │ • read • bash │ │ • QuickJS JS/TS │
│ • OpenAI (Chat/ │ │ • write • grep │ │ • Native descriptor│
│ Responses) │ │ • edit • find │ │ runtime │
│ • Gemini/Cohere │ │ • ls │ │ • Capability policy│
│ • Azure/Bedrock │ │ • ext-registered │ │ • Node shims │
│ • Vertex/Copilot│ │ │ │ • Event hooks │
│ • GitLab/Cursor │ │ │ │ • Runtime risk ctl │
│ /Ext │ │ │ │ │
└────────┬────────┘ └─────────┬──────────┘ └───────┬──────────┘
│ │ │
┌────────▼─────────────────────▼──────────────────────▼──────────┐
│ Session Persistence │
│ • JSONL format (v3) • Tree structure • Session index/cache │
│ • Per-project dirs • Default-enabled SQLite backend support │
└─────────────────────────────────────────────────────────────────┘
Provider-count rule: Pi has 11 native provider implementation modules. Those modules are anthropic, openai, openai_responses, gemini, cohere, azure, bedrock, vertex, copilot, gitlab, and cursor. User-visible provider IDs, aliases, OpenAI-compatible presets, and extension-provided streamSimple providers are counted separately because several native modules expose multiple routes. Shared support modules under src/providers/ (mod.rs, model_fetch.rs, extension_stream.rs, openai_completion.rs, openai_deepseek.rs, openai_openrouter.rs, openai_responses_complete.rs, and tool_schema.rs) are excluded.
#![forbid(unsafe_code)] enforced project-widesysinfo crate ensures no orphaned processesthiserror with specific error types per componentopt-level = 3 across both release and dist profilesThis Rust port preserves Pi's user experience, but intentionally changes the runtime substrate. The original TypeScript Pi (pi-mono, packages/coding-agent) is built on Node.js + package-level abstractions. pi_agent_rust moves those same behaviors onto asupersync primitives so lifecycle guarantees are explicit in the runtime model.
| Concern | TypeScript Pi (pi-mono baseline) | pi_agent_rust + asupersync |
|---|---|---|
| Runtime model | Node event loop + Promise/AbortSignal conventions | RuntimeBuilder + explicit reactor and runtime handle |
| Async ownership | Task lifetimes coordinated by framework/library code | Structured task ownership and explicit cross-thread channels (TUI/RPC bridging) |
| Cancellation semantics | Primarily API- and tool-layer conventions | Runtime-aware cancellation checks + bounded timeout handling in tools |
| I/O capability shape | Ambient Node APIs + extension layer policies | Capability-scoped context (AgentCx over asupersync::Cx) and explicit hostcall policy |
| HTTP streaming | Provider/client dependent | Purpose-built asupersync HTTP/TLS client feeding custom SSE parser |
| Deterministic test hooks | Conventional async test setup | asupersync test/runtime hooks used widely in unit/integration tests |
Why this is useful in practice:
These are the concrete invariants we rely on in this implementation:
Turn-scoped agent lifecycle
AgentStart, TurnStart, TurnEnd, and AgentEnd in a stable order.max_tool_iterations (default 50) to avoid unbounded self-tool loops.Abort and timeout behavior is explicit
bash timeout follows a clear escalation path: terminate process tree, grace period, then hard kill.Session writes are crash-resilient
Compaction is threshold-driven and boundary-aware
context_window - reserve_tokens.Capability policy is fail-closed and precedence-defined
Streaming parser tolerates real network chunking
data: fields, partial UTF-8 tails, and end-of-stream flush.The following asupersync principles are reflected directly in pi_agent_rust architecture:
AgentCx wraps asupersync::Cx at subsystem boundaries (agent/tools/session/rpc).Compared to the original TypeScript implementation, this shifts more correctness responsibility into the runtime and core algorithms themselves, instead of relying primarily on ecosystem conventions.
This is a second comparison pass focused on high-impact architectural deltas and rationale.
| Area | Original pi-mono (packages/coding-agent) | pi_agent_rust | Why this divergence exists |
|---|---|---|---|
| Distribution model | npm package (npm install -g @mariozechner/pi-coding-agent) | Single Rust binary (pi) | Remove Node runtime dependency and improve startup/deployment portability |
| Execution surfaces | Interactive + print + JSON mode + RPC + SDK | Interactive + print + JSON mode + RPC + Rust SDK | Rust SDK provides idiomatic companion API for embedding Pi programmatically (documented in docs/sdk.md) |
| Default built-in tool posture | Defaults to read/write/edit/bash (others available) | Fourteen Essential-tier built-ins always in the schema (read/write/edit/bash/grep/find/ls/hashline_edit/ask/todo/web_search/submit_plan/current_time/xdev), with a discoverable tier behind the xdev dispatcher | Keep common code-navigation, shell, and edit workflows available without extra configuration while bounding schema size |
| Extension trust model | Extension/package model documented as full system access | Embedded runtime with capability-gated hostcalls and policy profiles | Reduce ambient authority and make extension behavior auditable/deny-by-default |
| Session architecture emphasis | JSONL tree session model and branch navigation | JSONL v3 tree + derived SQLite metadata index + default-enabled SQLite session backend support | Bound eligible resume/lookups and coordinate multi-instance access |
| Streaming transport stack | Node runtime networking stack | Purpose-built HTTP/TLS client + custom SSE parser on asupersync | Tighter control over chunking, parsing, and failure handling in long streams |
| Cancellation/timeout mechanics | Platform/event-loop cancellation conventions | Explicit abort signaling, bounded tool iterations, process-tree termination | Minimize hangs/orphans and make stop behavior deterministic under load |
| Runtime context model | Framework-level conventions and extension APIs | Explicit AgentCx/asupersync::Cx capability-scoped context threading | Make effect boundaries and testability first-class architectural constraints |
Practical consequence of these deltas:
docs/parity-certification.json tracks informational functional-parity progress; it does not authorize strict replacement claims.This section compares concrete implementation mechanics for equivalent high-level behavior.
| Algorithm | pi-mono baseline mechanism | Rust implementation mechanism | Why the Rust variant exists |
|---|---|---|---|
| Session context rebuild after compaction | buildSessionContext() emits compaction summary, then messages from firstKeptEntryId (pre-compaction path), then post-compaction entries | to_messages_for_current_path() uses the same ordering and adds a fallback if first_kept_entry_id is missing | Avoid silent context loss when compaction anchors are orphaned/corrupted |
| JSONL persistence | Incremental append (appendFileSync) plus full rewrite (writeFileSync) for migrations/rewrites | Save via temp file + atomic persist/replace | Keep on-disk session state crash-resilient during save operations |
| Session discovery/resume | Directory/file scan and mtime sorting of JSONL files | Derived SQLite session metadata index + WAL + lock file + staleness-triggered full reindex | Bound resume lookup cost and coordinate concurrent processes |
| Compaction token accounting | Uses assistant usage (totalTokens else input+output+cacheRead+cacheWrite) plus heuristic trailing estimates | Uses assistant usage (total_tokens else input+output) plus heuristic trailing estimates; fixed image token estimate | Keep accounting stable across providers with uneven cache-token reporting while staying conservative |
| Cut-point + split-turn handling | Valid cut points exclude tool results; split turns are summarized as history + turn-prefix context | Same cut-point class and split-turn strategy, implemented in Rust entry/message model | Preserve tool-call/result adjacency and turn coherence under budget pressure |
| Bash timeout/process cleanup | Timeout/abort kills process tree (killProcessTree) and returns tail-truncated output | Timeout escalation (TERM then grace then KILL) + process-tree walk + shell exit trap + tail truncation | Enforce bounded cleanup and reduce descendant-process leaks from background jobs |
| Streaming event decoding | Transport semantics are exposed (sse/websocket/auto); parser details are runtime-internal | Explicit SSE parser with BOM stripping, CR/LF normalization, UTF-8 tail buffering, and flush-on-end | Make byte-to-event behavior deterministic and provider-SDK-independent |
The sections above compare mechanics. This section calls out concrete features present in this Rust port that are not part of the pi-mono baseline implementation model.
| Rust-port feature | Why it is useful/compelling |
|---|---|
pi doctor diagnostics command (text/json/markdown, --only, --fix, swarm preflight, extension compatibility checks) | Gives actionable environment + compatibility diagnostics, supports CI gating (non-zero on failures), can auto-fix safe issues like missing dirs/permissions, and reports read-only multi-agent readiness before swarm work |
Capability-gated extension policy profiles (safe / balanced / permissive) with per-extension overrides | Lets operators run shared extensions with explicit capability boundaries instead of ambient full-system access |
Secret-aware extension env filtering (pi.env() blocklist for keys/tokens/secrets) | Reduces accidental credential exposure from extension code paths |
Per-extension trust lifecycle + kill-switch audit trail (pending/acknowledged/trusted/killed, kill_switch, lift_kill_switch) | Supports immediate containment, explicit operator provenance, and controlled re-entry after review |
| Hostcall compatibility-lane emergency controls (global/per-extension forced-compat switches + reason codes) | Gives operators a deterministic rollback path for fast-lane incidents without losing extension availability |
| Runtime risk controller for extension hostcalls (configurable, fail-closed by default) | Adds another enforcement layer beyond static policy for suspicious runtime behavior in extension call flows |
Argument-aware runtime risk scoring for shell paths (dcg_rule_hit, dcg_heredoc_hit, heredoc AST inspection across Bash/Python/JS/TS/Ruby) | Detects destructive intent hidden in multiline scripts and wrapper commands before hostcall execution |
| Tamper-evident runtime risk ledger tooling (`ext_runtime_risk_ledger verify | replay |
| Unified incident evidence bundle export (risk ledger, security alerts, hostcall telemetry, exec mediation, secret-broker events) | Incident response can triage from one structured artifact set instead of stitching ad-hoc logs |
Opt-in hostcall reactor telemetry harness with optional NUMA slab pool (enable_hostcall_reactor: shard affinity, global-order drain, bounded queue backpressure) | Available to stress harnesses and explicit callers for backpressure testing while default production dispatch runs inline on fast/compat lanes |
| Cold realm factory + persistent transpile cache | Rebuilds mutable JS state for every load while reusing only versioned compiled artifacts that are safe to share across realms |
| Extension preflight static analysis (imports/forbidden-pattern scan with policy-aware hints) | Catches risky extension patterns before runtime execution |
| Node/Bun-compatible extension runtime without Node/Bun dependency (embedded QuickJS + shims) | Runs legacy extension workflows in a single native binary deployment model |
| Extension compatibility scanner + conformance harness | Makes extension support measurable and auditable instead of anecdotal |
| Derived SQLite session metadata index (WAL + lock + stale reindex path) | Gives fast session resume/list operations at scale without scanning every JSONL file on each query |
| Session Store V2 rollback and migration ledger (segmented log + checkpoints + rollback events) | Long-session recovery can unwind to a known checkpoint with explicit migration/rollback provenance |
Default-enabled SQLite session storage support (sqlite-sessions feature) | Supports deployments that want database-backed session persistence in addition to JSONL; disable with --no-default-features when building a minimal binary |
| Crash-resilient session save path (temp file + atomic persist) | Improves session-file durability during writes and reduces partial-write failure modes |
Unified hostcall dispatcher with typed taxonomy mapping (timeout / denied / io / invalid_request / internal) | Produces consistent extension/runtime error semantics and easier client handling |
Fail-closed evidence-lineage gates (run_id/correlation_id + cross-artifact lineage checks) | Rejects stale or cherry-picked conformance/perf artifacts at release-gate time |
| Structured auth diagnostics with stable machine codes | Improves troubleshooting and operational visibility without leaking sensitive credential material |
Pi deliberately uses advanced math where it improves runtime behavior or benchmark confidence. The goal is not “fancy formulas in docs”; it is safer policy decisions, faster recovery from workload shifts, and more trustworthy performance attribution.
In ExtensionManager (RegimeShiftDetectorState in src/extensions.rs), Pi combines CUSUM and Bayesian online change-point detection to detect load-regime changes early (for example when hostcall traffic suddenly spikes or stalls).
$$ S_t^+ = \max\left(0,;S_{t-1}^+ + (-z_t - k)\right), \quad S_t^- = \max\left(0,;S_{t-1}^- + (z_t - k)\right) $$
$$ H(r)=\frac{1}{\lambda}, \quad P(r_t=0 \mid x_{1:t}) \propto \sum_r P(r_{t-1}=r),H(r),P(x_t \mid r) $$
Intuition: CUSUM catches persistent drift; BOCPD catches sudden regime changes without brittle fixed thresholds.
Inside ExtensionManager (SafetyEnvelopeState in src/extensions.rs), Pi tracks nonconformity scores (absolute residuals from the running mean) with Gibbs-Candès Adaptive Conformal Inference (alpha_t online miscoverage updates) and treats out-of-interval events as anomalies.
$$ q = \text{score}_{\lceil (n+1)\cdot \text{confidence} \rceil - 1}, \quad \text{anomaly if } |x_t - \mu_t| > q $$
Intuition: thresholds adapt online from recent behavior and realized coverage instead of hard-coding one static latency cutoff.
SafetyEnvelopeState in ExtensionManager (src/extensions.rs) pairs the conformal envelope with a PAC-Bayes-kl bound over extension outcomes, and vetoes aggressive optimization when the bound is too high.
$$ \mathrm{kl}(\hat q ,|, q_{\text{bound}});\le;\frac{\mathrm{KL}(Q|P)+\ln!\left(2\sqrt{n}/\delta\right)}{n} $$
Intuition: this gives an explicit uncertainty-aware ceiling on true error risk before allowing more aggressive runtime behavior.
experimental-controllers)For offline trace replay and research evaluation (evaluate_off_policy in src/extension_scoring.rs, gated behind the opt-in experimental-controllers Cargo feature and not wired into default production dispatch), Pi evaluates candidate policy moves from trace data:
$$ w_i=\frac{\pi(a_i\mid x_i)}{\mu(a_i\mid x_i)}, \quad \hat V_{\text{IPS}}=\frac{1}{n}\sum_i w_i r_i $$
$$ \hat V_{\text{WIS}}=\frac{\sum_i w_i r_i}{\sum_i w_i}, \quad \hat V_{\text{DR}}=\frac{1}{n}\sum_i\left(\hat r_i + w_i(r_i-\hat r_i)\right) $$
$$ N_{\text{eff}}=\frac{(\sum_i w_i)^2}{\sum_i w_i^2}, \quad \Delta_{\text{regret}}=\bar r_{\text{baseline}}-\hat V_{\text{DR}} $$
Intuition: the evaluator fails closed if sample support is weak, uncertainty is high, or estimated regret is above threshold.
experimental-controllers)In src/extension_scoring.rs (plan_voi_candidates, gated behind the opt-in experimental-controllers Cargo feature for offline/experimental probe scheduling rather than default production dispatch), the VOI planner prioritizes probes that provide the most expected learning under a strict overhead budget.
$$ \text{priority}_i \propto \frac{\text{utility}_i}{\text{overhead}_i} $$
Intuition: run only the experiments that are likely to change decisions; skip stale or low-value probes.
For phase-1 matrix benchmarking, Pi computes stage attribution weighted by realistic workload size (session_messages) and reports confidence intervals.
\frac{\sum_i w_i,m_{i,s}}{\sum_i w_i,t_i}\cdot 100, \quad w_i=\text{session_messages}_i $$
$$ n_{\text{eff}}=\frac{(\sum_i w_i)^2}{\sum_i w_i^2}, \quad \mathrm{CI}{95}=\mu \pm 1.96\sqrt{\frac{\sigma^2}{n{\text{eff}}}} $$
Intuition: prioritize what dominates real end-to-end latency, not just isolated microbench hotspots.
ExtensionManager (OcoTunerState in src/extensions.rs) includes a live per-extension online convex tuner for queue/batch/time-slice budgets with explicit guardrail rollback behavior:
\mathrm{clip}!\left(\tau_t - \eta\nabla_{\tau}\mathcal{L}t,;\tau{\min},\tau_{\max}\right) $$
Intuition: the system adapts continuously, but if instantaneous loss exceeds a rollback threshold it immediately returns to a safer profile.
| Technique | Where in Pi | Why it helps |
|---|---|---|
| CUSUM + BOCPD | ExtensionManager (RegimeShiftDetectorState, live) | Detects traffic regime shifts early and robustly |
| Conformal intervals (ACI) | ExtensionManager (SafetyEnvelopeState, live) | Adaptive anomaly gating without static magic numbers |
| PAC-Bayes bound | ExtensionManager (SafetyEnvelopeState veto path, live) | Fails closed when uncertainty/risk is too high |
| IPS/WIS/DR + ESS | extension_scoring OPE (opt-in experimental-controllers) | Evaluates candidate policy changes offline with support/regret gates |
| VOI planning | extension_scoring VOI planner (opt-in experimental-controllers) | Allocates probe overhead budget to highest-value candidates in evaluation harnesses |
| Weighted attribution + CI | Phase-1 perf matrix reports | Ranks optimization work by realistic user impact |
| OCO + regret rollback | ExtensionManager (OcoTunerState, live) | Adapts budgets under load while bounding unsafe drift |
The SSE (Server-Sent Events) parser is a custom implementation that handles Anthropic's streaming response format. Unlike library-based approaches, the parser operates as a state machine that processes bytes incrementally:
Bytes → Line Accumulator → Event Parser → Typed StreamEvent
Key characteristics:
| Property | Implementation |
|---|---|
| Buffering | Zero-copy where possible; lines accumulated only when incomplete |
| Event types | 12 distinct variants: MessageStart, ContentBlockStart, ContentBlockDelta, ContentBlockStop, MessageDelta, MessageStop, Ping, Error, and thinking-specific events |
| Error recovery | Malformed events logged but don't crash the stream |
| Memory | Fixed-size rolling buffer prevents unbounded growth |
The parser handles edge cases like:
data: fields (concatenated with newlines)event: field appearing before or after data:Large outputs from tools (file reads, command output, grep results) must be truncated to avoid exhausting the LLM's context window. The truncation algorithm preserves usefulness while staying within limits:
┌─────────────────────────────────────────┐
│ Original Content │
│ (potentially huge) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ HEAD: First N/2 lines │
│ ───────────────────────── │
│ [... X lines truncated ...] │
│ ───────────────────────── │
│ TAIL: Last N/2 lines │
└─────────────────────────────────────────┘
Constants:
| Limit | Value | Rationale |
|---|---|---|
MAX_LINES | 2000 | Balances context usage vs. completeness |
MAX_BYTES | 1MB | Prevents binary file accidents |
GREP_MAX_LINE_LENGTH | 500 chars | Truncates minified code |
The algorithm:
MAX_LINES, takes first 1000 and last 1000MAX_BYTES, applies byte-level truncationThe bash tool must handle runaway processes, infinite loops, and fork bombs without leaving orphans. The implementation uses the sysinfo crate to walk the process tree:
// Pseudocode for process cleanup
fn kill_process_tree(root_pid: Pid) {
let system = System::new();
let children = find_all_descendants(root_pid, &system);
// Kill children first (deepest first), then parent
for child in children.iter().rev() {
kill(child, SIGKILL);
}
kill(root_pid, SIGKILL);
}
Timeout behavior:
To avoid orphaned background jobs (e.g. cmd &), the bash script installs an EXIT trap that waits for any remaining child processes and then exits with the original command's status.
This prevents the common failure mode where killing a shell leaves its children running.
Sessions use a tree structure rather than a flat list, enabling conversation branching (useful when exploring different approaches):
┌─────────┐
│ Message │ (root)
│ #1 │
└────┬────┘
│
┌────▼────┐
│ Message │
│ #2 │
└────┬────┘
│
┌──────────┼──────────┐
│ │
┌────▼────┐ ┌────▼────┐
│ Message │ │ Message │ (branch)
│ #3 │ │ #3b │
└────┬────┘ └────┬────┘
│ │
┌────▼────┐ ┌────▼────┐
│ Message │ │ Message │
│ #4 │ │ #4b │
└─────────┘ └─────────┘
JSONL format (v3):
Each line is a self-contained JSON object with a type discriminator:
{"type":"session","version":3,"cwd":"/project","created":"2024-01-15T10:30:00Z"}
{"type":"message","id":"a1b2c3d4","parent":"root","role":"user","content":[...]}
{"type":"message","id":"e5f6g7h8","parent":"a1b2c3d4","role":"assistant","content":[...]}
{"type":"model_change","id":"i9j0k1l2","parent":"e5f6g7h8","model":"claude-sonnet-4-20250514"}
The parent field creates the tree. Replaying a session walks the tree from root to the current leaf. Branching creates a new message with a different parent than the previous continuation.
The Provider trait abstracts over different LLM backends:
#[async_trait]
pub trait Provider: Send + Sync {
fn name(&self) -> &str;
fn api(&self) -> &str;
fn model_id(&self) -> &str;
async fn stream(
&self,
context: &Context<'_>,
options: &StreamOptions,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamEvent>> + Send>>>;
}
Context structure:
pub struct Context<'a> {
pub system_prompt: Option<Cow<'a, str>>, // System prompt
pub messages: Cow<'a, [Message]>, // Conversation history
pub tools: Cow<'a, [ToolDef]>, // Available tools with JSON schemas
}
StreamOptions:
pub struct StreamOptions {
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub api_key: Option<String>,
pub cache_retention: CacheRetention,
pub session_id: Option<String>,
pub headers: HashMap<String, String>,
pub thinking_level: Option<ThinkingLevel>,
pub thinking_budgets: Option<ThinkingBudgets>,
}
This design allows adding new providers (OpenAI, Gemini) without modifying the agent loop. Each provider translates the common types to its wire format and emits a unified StreamEvent stream.
Long conversations eventually exceed the model's context window. Pi's compaction algorithm reclaims space by summarizing older messages while preserving recent context.
The algorithm runs automatically after each agent turn when estimated token usage exceeds context_window - reserve_tokens:
┌──────────────────────────────────────────────────────────────┐
│ Full Conversation │
│ msg1 → msg2 → msg3 → ... → msgN-5 → msgN-4 → ... → msgN │
│ ├──── older messages ─────┤ ├─── recent messages ──────────┤ │
│ │
│ Step 1: Find cut point at a valid turn boundary │
│ Step 2: LLM summarizes msgs 1..N-5 into compact paragraph │
│ Step 3: Store Compaction entry in session JSONL │
│ Step 4: Next agent call uses [summary] + msgs N-4..N │
└──────────────────────────────────────────────────────────────┘
Token estimation counts tokens with real BPE tables (O200k/Cl100k, enabled by the default bpe-tokens feature); when BPE is unavailable it falls back to a conservative chars ÷ 3 heuristic for text, plus a flat 1,200 tokens per image. When an assistant message includes a usage field from the API, that measured value takes precedence over the estimate.
Cut point selection prefers boundaries between complete user-assistant turns. If the budget forces a mid-turn cut, the algorithm includes prefix messages from the split turn so the model retains context about what was being discussed at the boundary.
File operation tracking extracts read, write, and edit tool calls from the messages being summarized. The compaction prompt includes these paths so the summary preserves awareness of which files were examined or modified:
<read-files>
src/main.rs
src/config.rs
</read-files>
<modified-files>
src/auth.rs
</modified-files>
Configurable parameters:
| Parameter | Default | Purpose |
|---|---|---|
reserve_tokens | 8% of context window | Safety margin for response generation |
keep_recent_tokens | 10% of context window | Minimum recent context preserved |
Compaction can also be triggered manually with /compact in interactive mode or the compact RPC command.
Pi routes model requests through a provider factory that resolves the correct backend implementation from a (provider, model, api) tuple.
Resolution flow:
User specifies --provider openai --model gpt-4o
│
▼
┌──────────────────────────┐
│ Provider Metadata Table │ Maps "openai" → canonical ID,
│ │ determines API type (Completions
│ │ vs Responses vs custom)
└────────────┬──────────────┘
│
┌────────────▼──────────────┐
│ URL Normalization │ Appends /chat/completions,
│ │ /responses, or /chat depending
│ │ on detected API type
└────────────┬──────────────┘
│
┌────────────▼──────────────┐
│ Compat Config │ Applies per-model overrides:
│ │ system_role_name, max_tokens
│ │ field name, feature flags
└────────────┬──────────────┘
│
┌────────────▼──────────────┐
│ Provider Instance │ Anthropic | OpenAI | Gemini
│ │ Cohere | Azure | Bedrock | ...
└───────────────────────────┘
models.json overrides: Users can define custom providers in ~/.pi/agent/models.json or .pi/models.json. Each entry specifies a model ID, base URL, API type, and optional compat flags, letting you route to self-hosted models, proxies, or providers that Pi does not natively support.
Compat config handles the differences between OpenAI-compatible APIs:
| Override | Example | Purpose |
|---|---|---|
system_role_name | "developer" | o1 models use "developer" instead of "system" |
max_tokens_field | "max_completion_tokens" | Some models require a different field name |
supports_tools | false | Suppress tool definitions for models that reject them |
supports_streaming | false | Fall back to non-streaming for incompatible endpoints |
custom_headers | {"X-Custom": "val"} | Per-provider header injection |
Fuzzy matching: When a provider name doesn't match any known provider, Pi computes edit distance against all registered names and suggests the closest match in the error message.
Extensions run in an embedded QuickJS runtime (rquickjs crate) and communicate with Pi through a structured hostcall protocol. This is the mechanism that lets JavaScript code invoke Pi's built-in tools, make HTTP requests, and interact with the session, all without direct OS access.
Execution model:
┌─────────────────── QuickJS VM ───────────────────┐
│ │
│ extension.js calls: │
│ pi.tool("read", {path: "src/main.rs"}) │
│ │ │
│ ▼ │
│ enqueue HostcallRequest { │
│ call_id: "hc-0042", │
│ kind: Tool { name: "read" }, │
│ payload: { path: "src/main.rs" }, │
│ } │
│ │ │
│ ▼ │
│ return Promise (resolve/reject stored in map) │
│ │
└────────────────────────┬──────────────────────────┘
│
drain_hostcall_requests()
│
▼
┌── JsExtensionRuntimeHandle + ExtensionManager ────┐
│ │
│ 1. Check capability policy: │
│ read tool → requires "read" capability │
│ → Policy says: Allow / Deny / Prompt │
│ │
│ 2. If allowed → dispatch to ToolRegistry │
│ → Execute read tool │
│ → Get ToolOutput │
│ │
│ 3. complete_hostcall("hc-0042", Ok(result)) │
│ → Resolves the Promise in QuickJS │
│ │
│ 4. runtime.tick() │
│ → Drains Promise .then() chains │
│ → Extension JS continues execution │
│ │
└───────────────────────────────────────────────────┘
Live production hostcalls execute through JsExtensionRuntimeHandle + ExtensionManager shared dispatch (src/extensions.rs); the standalone ExtensionDispatcher harness (src/extension_dispatcher.rs) is gated behind the opt-in experimental-controllers Cargo feature for evaluation and bench isolation.
Capability mapping: Each hostcall kind maps to a required capability:
| Hostcall | Required Capability | Dangerous? |
|---|---|---|
pi.tool("read", ...) | read | No |
pi.tool("write", ...) | write | No |
pi.tool("bash", ...) | exec | Yes |
pi.http(request) | http | No |
pi.exec(cmd, args) | exec | Yes |
pi.env(key) | env | Yes |
pi.session(op, ...) | session | No |
pi.ui(op, ...) | ui | No |
pi.log(entry) | log | No (always allowed) |
Deduplication: Each hostcall's parameters are canonicalized (object keys sorted, structure normalized) and SHA-256 hashed. Identical requests within a short window can be deduplicated to avoid redundant tool executions.
Fast lane vs compatibility lane: Pi has two execution lanes for hostcalls:
tool and session operations). This avoids extra allocation and parsing work.For observability, each call is tagged with a stable lane key (for example tool|tool.read|filesystem or tool|fallback|filesystem) so latency and failure trends can be grouped consistently.
Built-in consistency guard (shadow dual execution, opt-in experimental-controllers): In the experimental-controllers evaluation harness (ExtensionDispatcher + DualExecOracle in src/extension_dispatcher.rs), Pi can sample read-only hostcalls, execute them through both lanes, and compare canonical output fingerprints, automatically backing off the fast lane if divergence crosses a configured budget.
Adaptive dispatch mode under load: Pi can switch between:
sequential_fast_path for simpler/low-contention workloadsinterleaved_batching when contention and queue pressure riseMode changes are gated by sample coverage and risk checks, so Pi does not switch based on thin or cherry-picked evidence.
Runtime telemetry for debugging and tuning: Pi records structured hostcall telemetry (pi.ext.hostcall_telemetry.v1) with lane choice, fallback reason, dispatch latency share, marshalling path, and optimization hit/miss fields. This is used by perf reports and reliability diagnostics.
Auto-repair pipeline: When an extension fails to load, Pi's loader repair path (src/extensions_js.rs) can automatically remediate common resolution issues within the extension root (while experimental IntentGraph/LISR governance, patch-proposal, canary, and forensic overlay modules live behind the opt-in experimental-controllers feature):
| Repair Mode | Behavior |
|---|---|
Off | No repairs |
Suggest | Log suggestions, don't apply |
AutoSafe (default) | Apply provably safe fixes (missing file paths, asset references) |
AutoStrict | Apply aggressive heuristic fixes (pattern-based transforms) |
Compatibility scanner: Before loading, Pi statically analyzes extension source code for imports, require() calls, and forbidden patterns (eval, Function(), process.binding, dlopen). The scan produces a capability evidence ledger that informs policy decisions.
Environment variable filtering: Extensions calling pi.env() hit a blocklist that denies access to API keys, credentials, tokens, and private keys. The filter blocks exact matches (ANTHROPIC_API_KEY, AWS_SECRET_ACCESS_KEY), suffix patterns (*_API_KEY, *_SECRET, *_TOKEN), and prefix patterns (AWS_SECRET_*, AWS_SESSION_*). Variables whose names do not match any secret pattern — including most PI_* variables — are served normally; there is no unconditional PI_* exemption, so a name like PI_EXAMPLE_API_KEY is blocked by the suffix rule.
Trust lifecycle and kill switch: Extension trust state is tracked explicitly (pending, acknowledged, trusted, killed). A kill switch demotes an extension to killed, quarantines it in the runtime risk controller, emits a critical alert, and writes an audit record. Lifting the switch requires an explicit operator action and moves the extension back to acknowledged.
ExtensionManager (src/extensions.rs) and extension_scoring (src/extension_scoring.rs) split runtime decision logic cleanly between live production controllers and opt-in evaluation modules:
ExtensionManager): RegimeShiftDetectorState (CUSUM + BOCPD), SafetyEnvelopeState (Adaptive Conformal Inference + PAC-Bayes veto bounds), and OcoTunerState (online convex budget tuning with guardrail rollback) monitor live hostcall traffic and fail closed toward conservative profiles under anomaly or overload.MeanField, src/extension_scoring.rs): Adjusts routing weights, batch budgets, and backoff/help factors based on queue pressure, latency, and starvation risk with damping and oscillation guards.experimental-controllers research/evaluation modules: VOI probe planning (plan_voi_candidates), off-policy evaluation (evaluate_off_policy IPS/WIS/DR + ESS), standalone ExtensionDispatcher + DualExecOracle (src/extension_dispatcher.rs), IntentGraph/LISR governance overlays (src/extensions_js.rs), and hostcall_io_uring_lane (src/hostcall_io_uring_lane.rs) are compiled for unit tests and explicit --features experimental-controllers evaluation builds rather than default production dispatch.The default interactive stack is FrankenTUI (src/interactive_ftui.rs, feature ftui, on by default since the 2026-08-25 cutover). It keeps the Elm Architecture (Model-Update-View): a driver thread owns an asupersync runtime plus an SDK agent session, agent events arrive through an AgentEventSubscription, and PiFtuiModel renders header, markdown conversation, status line, growing editor, and footer regions with tail-follow scrolling, per-entry render caching, inline ask cards, and modal overlays. All agent- and tool-originated text is sanitized before it reaches a frame. pi --inline draws the UI at the bottom of the terminal and preserves shell scrollback.
The previous stack, built on the charmed_rust library family (a Rust port of Go's Bubble Tea), lives in src/interactive.rs and is still selectable with pi --classic until it is deleted. The diagram below describes that classic stack; the FrankenTUI stack keeps the same agent/UI split and the same PiMsg event vocabulary.
Component stack (classic --classic stack):
┌────────────────────────────────────────────────────┐
│ Terminal (crossterm) │
│ Raw mode │ Alt screen │ Keyboard/Mouse events │
└──────────────────────┬─────────────────────────────┘
│
┌──────────────────────▼─────────────────────────────┐
│ bubbletea Program Loop │
│ Init() → Update(Msg) → View() → render cycle │
└──────────────────────┬─────────────────────────────┘
│
┌──────────────────────▼─────────────────────────────┐
│ PiApp (Model) │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │
│ │ TextArea │ │ Viewport │ │ Spinner │ │
│ │ (editor) │ │ (convo) │ │ (status) │ │
│ └─────────────┘ └──────────────┘ └─────────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Overlay Stack │ │
│ │ Model Selector │ Session Picker │ /tree │ │
│ │ Settings UI │ Theme Picker │ Branches │ │
│ │ Capability Prompt (extension UI) │ │
│ └─────────────────────────────────────────────┘ │
└──────────────────────┬─────────────────────────────┘
│
async channels (mpsc)
│
┌──────────────────────▼─────────────────────────────┐
│ Agent Async Task │
│ Runs on asupersync runtime │
│ Streams provider responses │
│ Executes tools │
│ Sends PiMsg events back to TUI thread │
└────────────────────────────────────────────────────┘
The async/sync bridge: The agent runs on the asupersync async runtime in a separate thread. It communicates with the bubbletea UI thread through mpsc channels. Each streaming event (text delta, tool start, tool update, agent done) becomes a PiMsg variant delivered to PiApp::update(), keeping the UI responsive during API streaming and tool execution.
Viewport scrolling: The conversation viewport tracks whether the user is at the bottom. When new content arrives and the user hasn't scrolled up, the viewport auto-follows the stream tail. Scrolling up disables auto-follow; pressing End or typing a new message re-enables it.
Overlay system: Modal UIs (model selector, session picker, branch navigator, extension capability prompts) stack on top of the main conversation view. Each overlay captures keyboard input until dismissed. Only the topmost active overlay receives events.
Slash commands available in the interactive editor:
| Command | Action |
|---|---|
/help (/h, /?) | Show available commands and keybindings |
/model (/m) or Ctrl+L | Open model selector with fuzzy search; /model roles edits role bindings |
Ctrl+P / Ctrl+Shift+P | Cycle scoped models forward/backward |
/login, /logout | Provider OAuth/API-key credential management |
/thinking <level> (/t) | Change thinking level mid-conversation |
/scoped-models (/scoped) | Show or set model scope patterns |
/tree, /fork | Browse the conversation tree; branch from a previous message |
/clear (/cls), /new | Clear conversation; start a new session |
/compact [shake|aggressive] | Manual compaction (shake drops oversized tool results with no LLM call) |
/checkpoint, /rewind, /fresh, /retry | Session restore points and turn control |
/undo, /redo | Revert/replay file mutations made by tools |
/resume (/r), /session (/info), /name, /history | Session picker, info, naming, input history |
/settings, /theme, /hotkeys (/keys), /changelog | Settings UI, themes (incl. auto), keybindings, changelog |
/plan, /approval, /advisor | Plan mode, approval modes, second-model turn review |
/goal status | Inspect a saved objective; see goal commands. First released in v0.9.0 |
/btw <question>, /tan <work> | Ephemeral smol-role side question; background task-role tangential work |
/mcp, /usage, /rules, /omfg | MCP server status, provider credit/quota, stream rules, grievances |
/export, /share, /copy (/cp) | HTML export, secret/unlisted GitHub Gist share (not private; anyone with the URL can view it), copy last reply |
/handoff, /commit, /review | Handoff document, dependency-ordered commit splitting, review |
/template, /skill:<name> | Expand a prompt template; invoke a skill |
/reload | Reload skills/prompts/themes/extensions from disk |
/exit (/quit, /q) or Ctrl+C | Exit Pi |
Live stream rules: /rules manages corrections enforced during generation
on every native agent surface. Matching assistant text or thinking interrupts
the response before its tool calls execute, adds the rule's directive, and
retries within a three-correction turn budget. Project rules require workspace
trust; triggered corrections survive compaction on their active branch. See
Stream rules for configuration and examples.
Use /mcp list to inspect each server's selected source, trust decision, and
connection health. /mcp trust <name> acknowledges that exact definition;
HTTP servers that need OAuth can then sign in with /mcp reauth <name>.
Follow the authorization URL and complete the browser callback. A successful
reauthentication replaces the live connection and reloads its tools, including
in RPC and ACP sessions.
Reauthentication also repairs an expired configured Authorization header.
After login succeeds, Pi removes that header from the file that supplied the
winning definition and preserves its existing trust acknowledgement for that
specific repair. Explicit --mcp-config files take precedence over .pi,
.agents, global Pi, and imported tool configurations. Shadowed files,
unrelated settings, and authored variable or secret references remain intact.
If the selected file changes while the browser is open, Pi preserves the edit
and refuses the repair. ACP and extension definitions remain owned by their
clients: their explicit login takes over only the exact supplied definition
without creating a replacement configuration file.
/mcp unauth <name> removes the managed login and retires the connection and
tools. Logout suppresses the old configured bearer as well, and a late browser
callback cannot restore a logged-out session. Cancelling the browser wait
preserves the previous credentials, source, and trust. If login succeeds
but source persistence or reconnection fails, Pi reports that the login was
saved so the remaining problem can be repaired without mistaking it for a
failed authorization.
For a server's third-party authorization, Pi also supports MCP URL elicitation. The host picker shows the complete URL and destination host before you choose to open it in an external browser, acknowledge opening it yourself, decline, or cancel. The manual option works when Pi runs remotely. Pi returns your consent decision without reading the browser page or treating it as completed authorization. See server-requested browser interactions.
Native settings support the OMP project-configuration switch:
{
"mcp": {
"enableProjectConfig": false
}
}
The default is true. When the merged setting is false, automatic discovery
skips project .pi and .agents MCP files and imported project configurations.
Global Pi configuration and explicit --mcp-config arguments remain eligible.
Project configuration also requires workspace trust when the setting is
enabled. Client-supplied ACP servers remain explicit session definitions, and
each server still requires its own trust acknowledgement.
The RPC mode (pi --mode rpc) exposes a line-delimited JSON protocol over stdin/stdout for programmatic integration. Each line is a self-contained JSON object.
Client → Pi (stdin):
{"type": "prompt", "message": "Explain this function", "id": "req-001"}
{"type": "steer", "message": "Focus on error handling"}
{"type": "follow_up", "message": "Now add tests"}
{"type": "abort"}
{"type": "get_state"}
{"type": "compact", "reserveTokens": 8192, "keepRecentTokens": 20000}
Pi → Client (stdout):
{"type": "agent_start", "sessionId": "..."}
{"type": "message_update", "message": {...}, "assistantMessageEvent": {"type": "text_delta", "delta": "The function", "contentIndex": 0}}
{"type": "tool_execution_start", "toolCallId": "...", "toolName": "read", "args": {}}
{"type": "tool_execution_end", "toolCallId": "...", "toolName": "read", "result": {}, "isError": false}
{"type": "agent_end", "sessionId": "...", "messages": [...]}
{"type": "response", "id": "req-001", "command": "prompt", "success": true, "data": {"status": "ok"}}
Fatal errors (JSON and RPC modes): a failure that ends the process — a bad config file, no credentials for the selected model, an unwritable state directory, a usage error — prints exactly one record on stdout before the non-zero exit, so a host never has to parse stderr prose:
{"type": "error", "phase": "startup", "code": "auth.missing_api_key", "message": "No API key found for provider anthropic. Set env var or use --api-key.", "exit_code": 1}
phase is startup when nothing had been written to stdout yet (no session header, no RPC loop) and run otherwise. code is stable: the auth diagnostic codes (auth.missing_api_key, auth.no_models_available, auth.invalid_api_key, auth.quota_exceeded, auth.oauth.token_refresh_failed, …) when the failure classifies as one, else the family — config, session, provider, auth, tool, usage (argument/validation errors, exit code 2), extension, io, json, state_store, aborted, api, or internal. The human-readable diagnosis with hints still goes to stderr. Text mode prints nothing on stdout.
I/O architecture: Two dedicated threads handle stdin reading and stdout writing, bridged to the async agent runtime via channels. The stdin thread retries on transient errors to prevent dropped input. The stdout thread flushes after every line to prevent buffering delays.
Message queuing: While the agent is streaming a response, incoming messages are routed to one of two queues:
| Queue | Behavior | Use Case |
|---|---|---|
| Steering | Interrupts current response; processed on next turn | Course corrections |
| Follow-up | Queued until current response completes | Sequential instructions |
Queue modes (All or OneAtATime) control whether multiple queued messages are batched into a single turn or processed individually.
Extension UI over RPC: When an extension requests user input (capability prompt, selection dialog), Pi emits an extension_ui_request event. Response-bearing events include a requestGeneration correlation token, which the client must echo alongside requestId in its extension_ui_response; this prevents a late response from resolving a newer request that reused the same public ID. IDE extensions can then present native UI for capability decisions instead of falling back to terminal prompts.
Session resume (pi -c or pi -r) needs to find the most recent session for the current project without scanning every JSONL file on disk. Pi maintains a SQLite index (session-index.sqlite) that provides constant-time lookups.
Schema:
CREATE TABLE sessions (
path TEXT PRIMARY KEY,
id TEXT NOT NULL,
cwd TEXT NOT NULL,
timestamp TEXT NOT NULL,
message_count INTEGER NOT NULL,
last_modified INTEGER NOT NULL,
size_bytes INTEGER NOT NULL,
name TEXT
);
Update lifecycle:
pi -c queries WHERE cwd = ? ORDER BY last_modified DESC LIMIT 1pi -r queries the same table and presents a picker sorted by recencyConcurrency: A file-based lock (session-index.lock) serializes writes from concurrent Pi instances. Reads use WAL mode for non-blocking access.
Staleness-based reindexing: If the index is older than a configurable threshold, Pi runs a full re-scan of the sessions directory to catch files created by other instances or manual edits. The re-scan keeps the index accurate without a centralized daemon.
Pi also supports a v2 sidecar store next to JSONL sessions for faster resume and stronger corruption checks on long histories.
What it adds:
How resume works:
clean source-state record, allowing the normal
v2 open to use the sidecar index + segments without rescanning the full JSONL file.dirty; dirty, invalid, or
otherwise stale sidecars fall back to authoritative JSONL parsing. Filesystem mtimes remain
a secondary external-change check, and legacy sidecars are fully verified once before use.Integrity strategy:
CLI & opt-in live sync support:
sessionStore: "v2" in settings.json (or PI_SESSION_STORE=v2 in the environment) to enable live incremental .v2 segment/index synchronization alongside canonical JSONL writes (default remains JSONL v3 without live sidecar syncing).pi migrate <path> --dry-run validates migration without writing.pi migrate <path> performs JSONL-to-v2 migration and verifies parity.Beyond simple API keys, Pi supports OAuth, AWS credential chains, service key exchange, and bearer-token auth. Credentials are stored in ~/.pi/agent/auth.json with file-locked access to prevent corruption from concurrent instances. Stored API keys can be literal strings, $ENV:VAR_NAME references, or $CMD:shell command / $COMMAND:shell command sources that resolve trimmed stdout at request time.
| Mechanism | Providers | Details |
|---|---|---|
| API Key | Anthropic, OpenAI, Gemini, Cohere, and many OpenAI-compatible providers | Static key via env var or settings |
| OAuth | Anthropic, OpenAI Codex, Google Gemini CLI, Google Antigravity, Kimi for Coding, GitHub Copilot, GitLab, and extension-defined OAuth providers | PKCE/state-validated flow with automatic refresh; Kimi uses device flow |
| AWS Credentials | Bedrock | Access key + secret + optional session token; region-aware |
| Service Key | SAP AI Core | Client ID/secret exchange for bearer token |
| Bearer Token | Custom providers | Static token in auth storage |
OAuth token lifecycle:
pi with an OAuth-configured providerauth.json for an existing tokenauth.jsonGoogle CLI-style OAuth providers carry project metadata with the token payload. Pi preserves and refreshes that payload and can resolve project IDs from GOOGLE_CLOUD_PROJECT or local gcloud config when needed.
Credential status reporting: pi config shows the status of each configured provider's credentials: Missing, ApiKey, OAuthValid (with time until expiry), OAuthExpired (with time since expiry), AwsCredentials, or BearerToken.
Diagnostic codes: Auth failures produce specific diagnostic codes (MissingApiKey, InvalidApiKey, QuotaExceeded, OAuthTokenRefreshFailed, MissingAzureDeployment, MissingRegion, etc.) with context-specific error hints rather than generic messages.
Read file contents (optionally images):
Input: { "path": "src/main.rs", "offset": 10, "limit": 50 }
Execute shell commands with timeout and output capture:
Input: { "command": "cargo test", "timeout": 120 }
timeout: 0 to disable the default timeoutSurgical string replacement:
Input: { "path": "src/lib.rs", "old": "fn foo()", "new": "fn bar()" }
Search files, internal documents, or a web page:
{ "pattern": "TODO", "path": "src/", "context": 2, "limit": 100 }
{ "pattern": "FEATURE_X", "path": ".;!vendor;!gen" }
{ "pattern": "track\\(", "path": "src;!*.test.ts;!src/legacy" }
{ "pattern": "critical|warning", "path": "agent://reviewer/findings;local://review-notes", "ignoreCase": true }
{ "pattern": "migration", "path": "skill://release/references/checklist.md" }
{ "pattern": "deprecated", "path": "https://example.com/changelog" }
{ "pattern": "data-version", "path": "https://example.com/changelog:raw", "literal": true }
.gitignore and workspace boundaries. hashline: true provides edit anchors for filesystem results.path: "root;!glob;!glob" (up to 64 entries and 64 KiB). A bare name such as !vendor matches at any depth below the root; a slash-containing pattern such as !src/legacy or !./gen is anchored to the working directory. Use !**/generated to match a directory at any depth. Exclusions alone default to the working directory, and explicitly named roots remain searchable. Existing filenames containing ! or semicolons retain their literal meaning. Both search backends prune exclusions before counting matches, while included paths retain normal permission checks. Use separate calls for multiple filesystem roots or resource URLs.read, including accepted agent:// results and JSON fields, skills, prompts, scratch notes, merge conflicts, PRs, issues, and SSH documents. Pending or rejected child output retains its normal access restrictions. Separate up to 16 internal URLs with semicolons; filesystem paths and HTTP URLs use separate calls.:raw to search the fetched source. Semicolons inside an HTTP URL remain part of that URL. The existing read.urlAllowPrivateTargets setting governs private-network access, with the same redirect checks as read. PR, issue, SSH, and conflict lookups retain their process effects for execution approval.glob and hashline apply to filesystem searches; virtual document line numbers are search locations.Discover files by pattern:
Input: { "pattern": "*.rs", "path": "src/", "limit": 1000 }
fd required)List directory contents:
Input: { "path": "src/", "limit": 500 }
/CLI tools have different performance requirements than servers or GUI applications. The critical metric is time-to-first-interaction: how quickly can the user start typing after invoking the command?
| Phase | Managed-runtime CLI | Pi's native binary |
|---|---|---|
| Application runtime bootstrap | Required | Not required |
| Application module loading | Commonly dynamic | Ahead-of-time linked Rust code |
| JIT warmup | Runtime-dependent | Not used |
| Current release timing | Not measured here | Fresh comparative measurement pending |
Current comparative timing numbers are intentionally omitted until a fresh, provenance-matched benchmark run is available.
Pi applies performance-oriented design at multiple layers, not only in the Cargo release profile.
Where performance work is concentrated:
These mechanisms are intended to preserve responsiveness under streaming, tool, large-session, and extension workloads. Achieved release-level latency and memory results require fresh, provenance-matched measurements.
This catalog reflects a long sequence of changes across runtime, storage, streaming, and UI.
Concrete engineering work in this codebase includes:
| Area | What we built | Why it matters |
|---|---|---|
| Extension dispatch core | Typed hostcall opcode fast paths, compatibility fallback lane, zero-copy payload arena, canonical-hash shortcuts, interned operation paths | Cuts per-call overhead on the hottest extension operations while preserving correctness fallback paths |
| Registry/policy lookup | Immutable policy snapshots with O(1) capability checks, plus RCU-style metadata snapshots for extension registry/tool metadata | Removes repeated dynamic lookup overhead in hot authorization/dispatch paths |
| Queueing + concurrency | Direct inline fast/compat lane dispatch by default, plus opt-in HostcallReactorMesh shard-queue backpressure telemetry (enable_hostcall_reactor) and budget-controller fallback guards | Avoids extra mutex/clone overhead on normal calls while keeping bounded overflow fallback and backpressure testing available on demand |
| Batched execution | AMAC-style interleaved batch executor with stall-aware toggling | Avoids head-of-line stalls when many independent hostcalls are in flight |
| IO specialization | Opt-in experimental-controllers io_uring lane policy + telemetry and explicit executor-unavailable fallback | Evaluates IO-heavy call policy in experimental builds without presenting the placeholder bridge as real io_uring execution |
| Runtime startup for extensions | Cold owner-isolated QuickJS realms, prebaked pi prelude + node:* virtual-module bytecode hydration, bounded in-realm source caches, and versioned persistent transpile caching | Avoids mutable-realm reuse while reducing repeated JS prelude/shim parsing and transpilation work |
| JS bridge/scheduler path | Pending-job fast-path tuning and bridge-level dispatch cleanup in hot extension loops | Reduces overhead between JS requests and Rust execution |
| Adaptive control loops | Live ExtensionManager regime-shift detection (CUSUM/BOCPD), ACI conformal + PAC-Bayes safety envelopes, OCO budget tuner, and mean-field shard controls (plus opt-in experimental-controllers VOI planner and OPE gates) | Lets live runtime behavior adapt safely to workload shifts while keeping offline research evaluators opt-in |
| Fast-path safety | Opt-in experimental-controllers shadow dual-execution sampling (ExtensionDispatcher + DualExecOracle) with automatic rollback/backoff on divergence | Verifies fast-lane vs compatibility-lane parity in evaluation harnesses without silently changing semantics |
| Trace-level optimization | Hostcall superinstruction compiler + tier-2 trace-JIT path | Fuses repeated opcode traces and lowers repeated dispatch overhead |
| Tool execution strategy | Effect-compatible tool classification + barrier-aware parallel execution paths | Increases throughput when multiple tool calls can safely run together without reordering mutating tools |
| Session write path | Write-behind autosave queue, durability modes, incremental append, checkpointed rewrite strategy, single-buffer append serialization | Keeps interaction fast while still supporting stronger durability when needed |
| Session index path | Async coalesced index updates, pending-drain hot-path tuning, and reduced allocation/boxing overhead | Keeps resume/discovery metadata updates off the interactive hot path |
| Session resume path | Session Store V2 sidecar (segmented log + offset index), O(index+tail) open path, stale-sidecar detection, migration/rollback tooling | Avoids full-file rescans on large histories and improves recovery behavior |
| Long-session maintenance | Background compaction/snapshot workers with quotas + lazy hydration paths | Controls session growth and keeps long-running workspaces responsive |
| Compaction internals | Binary-search cut-point logic, serialization helper extraction, and zero-allocation-oriented cleanup on compaction paths | Lowers compaction overhead and keeps compaction from becoming a pause source |
| Streaming internals | SSE parser event-type interning, scanned-byte tracking (scanned_len), UTF-8 recovery hardening | Reduces repeated scanning/allocation during incremental response streaming and improves resilience |
| Provider/message memory path | Zero-copy request context migration (Cow), Arc-based message/result sharing, clone elimination in stream end paths | Removes hot-path cloning and allocation churn in core agent/provider loops |
| TUI rendering path | Message render cache, conversation-prefix cache, reusable render buffers, viewport/render-path refactors, Criterion perf gates | Reduces redraw cost and jitter while streaming long outputs |
| Startup/resource loading | Parallelized skill/prompt/theme loading plus precomputed tool definitions/command names | Moves heavy initialization off the critical path to improve time-to-interaction |
| Allocator/build profile | Speed-optimized release and dist profiles (opt-level = 3, fat LTO, strip), opt-in jemalloc benchmark variants, strict artifact validation for perf claims | Maximizes runtime speed for shipped binaries while keeping benchmark provenance and reporting drift-free |
| Perf governance | Scenario matrix, claim-integrity gates, strict no-data fail behavior, variance/confidence artifacts, reproducible orchestration bundles | Makes performance claims auditable and regression detection automatic |
| Hostcall marshalling planner | HostcallRewriteEngine uses a small cost model to pick fast opcode fusion only when it is clearly cheaper and unambiguous; otherwise it stays on the canonical path and records fallback reason | Gains speed on hot marshalling shapes without risking silent semantic drift from ambiguous rewrites |
| Tool text-processing hot path | truncate_head/truncate_tail use lazy line traversal and memchr line counting; normalization switched to a single-pass transform instead of chained string rewrites | Large file/tool outputs avoid unnecessary intermediate allocations and stay responsive |
| JS bridge regex and parser micro-paths | Frequent regex checks in the extension JS bridge are OnceLock-cached; hot bridge calls avoid repeated setup work | Cuts repeated per-call overhead in extension-heavy sessions |
| CLI/autocomplete process-spawn reduction | fd/rg availability checks are cached, and autocomplete file-index refresh runs in background with stale-update dropping | Keeps completion and command handling quick even in very large repositories |
| Session identity/index micro-optimizations | O(1) entry-id cache, single-pass metadata finalization, and append-path cleanups replace multi-pass/copy-heavy behavior | Reduces overhead on append/save/rebuild when sessions become large |
| Benchmark-driven rollback discipline | Candidate micro-optimizations are benchmarked and can be reverted when real workloads regress (for example, a newline-scan memchr swap in SSE was rolled back) | Prevents "optimizations" that look fast in theory but slow down real usage |
Optimization spans algorithms, execution lanes, memory movement, queue discipline, storage layout, and validation policy as one system.
Cargo.toml defines [profile.release] (opt-level = 3) so both cargo build --release / cargo install and DSR's [profile.dist] shipping builds optimize for runtime speed:
[profile.release]
opt-level = 3 # Optimize generated code for runtime speed
lto = true # Link-time optimization across all crates
codegen-units = 1 # Single codegen unit (slower compile, better optimization)
panic = "abort" # No unwinding machinery
strip = true # Remove symbol tables
Default builds keep heavyweight extras opt-in; use --features full
when you need the image, clipboard, wasm, jemalloc, and syntax-highlighting
extras in one build.
Published binaries (GitHub Releases, the installer, pi self-update) are built
by DSR with --profile dist (build_profile: dist). It inherits LTO, single-codegen-unit, panic = "abort", and symbol stripping from release while setting
opt-level = 3, so the binaries people download are optimized for runtime speed without an arbitrary shipping binary-size ceiling.
Pi separates performance evidence artifacts from distributable release artifacts:
scripts/perf/orchestrate.sh and scripts/bench_extension_workloads.sh, and must carry
run provenance (correlation_id) plus profile labels (for example build_profile=perf).dist profile
(release with opt-level = 3) and distributed via GitHub Releases + installer paths.Policy implication: release/size artifacts alone are not valid evidence for global performance
claims. Performance claims must cite benchmark evidence bundles with reproducible provenance.
See docs/testing-policy.md and docs/releasing.md for normative policy details.
Current checked-in performance evidence state:
Run output: tests/perf/reports/ (budget_summary.json, PERF_BUDGETS.md)
Current budget summary (generated 2026-11-21; source_commit unbound, no run
id, no correlation id, strict_mode false): 19 declared budgets, of which
0 PASS, 0 FAIL and 19 NO_DATA. Header and per-budget budget_results
rows now agree, and they agree on this: the tree carries no performance
measurements at all. Claim readiness is blocked,
performance_claims_authorized is false, and the blocking reason codes are
budget_data_missing, ci_budget_data_missing, correlation_id_missing,
data_contract_failure, run_id_missing, source_commit_unbound, and
strict_mode_disabled.
Counts are value-bound to the artifact:
(from tests/perf/reports/budget_summary.json; no performance claim)
Before spending time on a definitive refresh, run
python3 scripts/perf/preflight_budget_inputs.py to list missing budget
inputs, expected artifact paths, and RCH-only refresh commands.
Orchestrated perf runs also write
results/perf_budget_preflight_before_refresh.json before any
budget_summary.json refresh and results/perf_artifact_staging_manifest.json
after collection. The staging manifest records each required artifact's source
path, RCH remote-source prefix when supplied via PERF_REMOTE_TARGET_DIR,
retrieved local path, schema, size, mtime, checksum, and explicit blocker
status.
Perf evidence cache entries live under
PERF_EVIDENCE_CACHE_DIR (default:
$CARGO_TARGET_DIR/perf/evidence_cache) with schema
pi.perf.evidence_cache.v1. Preflight and staging may reuse cached evidence
only when the entry's schema, command, git commit, build profile, run
ID/correlation ID, host/toolchain provenance, checksum, and TTL validate; reused
artifacts are labeled source_kind=cache/evidence_source=cache in the JSON
outputs. Override the cache lifetime with
PI_PERF_EVIDENCE_CACHE_TTL_HOURS.
env_fingerprint.json records cgroup-aware host topology with schema
pi.perf.host_topology_fingerprint.v1: cgroup v2 CPU quota, cpuset size,
memory limits, NUMA node count, caveats, and a constrained budget_profile
for containerized hosts.
Regenerate the perf evidence bundle before adding release-facing speed, throughput, memory, or startup numbers to this README.
Full-suite gate at its latest regeneration (2026-11-25): 19/20 gates passed with 13/14 blocking gates (ext_must_pass now passes at 208/208; the sole remaining blocking failure is practical_finish_checkpoint, waiting on 1 open technical PERF-3X issue bd-3ar8v.2.8) (from tests/full_suite_gate/full_suite_verdict.json; historical snapshot)
Unified evidence bundle, as regenerated 2026-11-21: 30 total sections, 18 present, 12 missing, 0 invalid (bundle verdict: partial) (from tests/evidence_bundle/index.json; historical snapshot)
Historical drop-in result: 22/22 certification gates passed, overall verdict CERTIFIED for source 52e9fbfb24352045985b59df9d7ea63f1f8f2ef8 only (from the verdict blob stored at Git revision 2fc4b8c0b77ded267cf5e0f517f4b6fa87f45e91, not from the live verdict file)
Extension must-pass gate, as regenerated 2026-11-25: 208/208 must-pass extensions passed (0 failures); informational stretch set 17/19 passed (from tests/ext_conformance/reports/gate/must_pass_gate_verdict.json; historical snapshot)
Context-intelligence closeout gate: pass, with child Beads mapped to code, tests, docs/evidence, validation commands, pushed commits, redaction posture, perf-budget evidence, README freshness, staged UBS, and Beads ledger reconciliation (from docs/evidence/context-intelligence-closeout-gate.json; historical snapshot)
Progress SLO closeout gate: pass, with child Beads mapped to code, tests, docs/evidence, validation commands, pushed commits, source-boundary checks, stress-budget evidence, README freshness, staged UBS, and Beads ledger reconciliation (from docs/evidence/swarm-progress-slo-closeout-gate.json; historical snapshot)
Runtime-intelligence closeout gate: pass, with child Beads mapped to compaction admission, tool-output artifacts, provider routing, scheduler fairness, frame-budget telemetry, cancellation cleanup, extension safety provenance, docs/evidence, source-boundary checks, pushed commits, staged UBS, and Beads ledger reconciliation (from docs/evidence/runtime-intelligence-closeout-gate.json; historical snapshot)
Use the registered DSR recipe for day-to-day validation and definitive benchmark evidence:
dsr quality --tool pi_agent_rust.tests/perf/reports/phase1_matrix_validation.jsontests/full_suite_gate/full_suite_verdict.jsontests/full_suite_gate/certification_verdict.jsontests/full_suite_gate/extension_remediation_backlog.jsonDirect Cargo, RCH, and repository wrapper invocations are not evidence and are not an authorized fast path around DSR.
Pi includes a dedicated ext_workloads workload harness for extension runtime
bottlenecks. Run it only through the registered DSR performance lane, which
writes ext_workloads.jsonl, ext_hostcall_hotspot_matrix.json, and
ext_hostcall_bridge_trace.jsonl with DSR provenance.
This harness does more than raw timing:
marshal, queue, schedule, policy, execute, iopi.ext.hostcall_hotspot_matrix.v1) for quick bottleneck rankingpi.ext.hostcall_trace.v1) for per-call debuggingpi.ext.voi_scheduler.v1) to recommend the next highest-value experiments under a fixed overhead budgetIn plain terms: it helps answer "what should we optimize next?" with data, not guesswork.
For multi-agent operator handoff, scripts/build_swarm_operator_runpack.py can
also project a diagnostic-only bottleneck_attribution dashboard from the tail
latency report, swarm flight recorder report, swarm resource preflight,
hostcall admission swarm profile, session recovery swarm profile, concurrent
RPC swarm E2E evidence, and RCH artifact-sync preflight. The dashboard is
operator evidence only; release-facing speed, drop-in, or performance claims
still require the claim-integrity gates below to pass.
The runpack also embeds predictive_telemetry_ledger
(pi.swarm.predictive_telemetry_ledger.v1) and can write it separately with
--out-predictive-telemetry-ledger-json or print it with
--print-predictive-telemetry-ledger. The ledger is read-only advisory
evidence: it joins existing RCH, Agent Mail, Beads, turn-pressure,
bottleneck-attribution, and claim-readiness signals into ordered pressure
observations and next-bottleneck hypotheses, but it does not mutate the
scheduler, Agent Mail, RCH, Beads, git, or release/capacity claims.
The runpack also embeds validation_scheduler_plan
(pi.swarm.validation_scheduler_plan.v1) and can write it separately with
--out-validation-scheduler-plan-json or print it with
--print-validation-scheduler-plan. This is an advisory RCH-aware simulator:
it ranks fast script checks, evidence regeneration, focused tests,
E2E/conformance, compiler checks, and linting from the current git
change profile, predictive telemetry, RCH admission, remote proof, and target
cache evidence. It preserves exact command strings and required RCH env, but it
does not execute cargo, mutate RCH, reserve Agent Mail, claim Beads, delete temp
artifacts, or allow heavy cargo to fail open into a local build.
If validation-broker status or plan JSON is supplied with
--validation-broker-json, the runpack projects source status, slot counts,
stale slot warnings, duplicate-gate opportunities, and recommended next actions
as advisory handoff data. This projection does not replace DSR, Doctor, Beads,
Agent Mail, UBS, or release-claim gates. Operator
workflow, privacy, and degraded-data guidance lives in
docs/swarm-operations-runbook.md#validation-broker-operator-workflow.
If progress SLO JSON is supplied with --progress-slo-json, the runpack
projects the current swarm progress posture, confidence, saturation summary,
source freshness, redaction posture, and next actions as advisory handoff data.
This projection does not replace Beads, Agent Mail, RCH, Doctor, validation
gates, git, or release-claim gates. Operator workflow, privacy, degraded-source
handling, stale-Beads handling, RCH pressure interpretation, and no-open-work
convergence guidance lives in
docs/swarm-operations-runbook.md#progress-slo-operator-workflow.
The same runpack command can emit a dry-run swarm autopilot input pack and plan
beside the handoff bundle. When those companion artifacts are requested, the
runpack JSON/Markdown includes an autopilot_handoff summary
(pi.swarm.autopilot_handoff.v1) with
pi.swarm.autopilot_input_pack.v1 and pi.swarm.autopilot_plan.v1 schema
references, selected advisory action, artifact paths, and source provenance.
The autopilot never mutates ownership or replaces Doctor, Beads, Agent Mail,
RCH, git, or the source artifacts; it only turns those inputs into reproducible
operator next-action guidance. Its work-admission gate includes a read-only
dry-run executor that classifies plan items as would_execute, blocked,
requires_operator, or never_execute so deletion requests, Agent Mail/RCH
mutation, local heavyweight Cargo, and Beads ownership bypasses are rejected
without executing anything.
For degraded-coordination handoff proof, the runpack script also has a no-mock
E2E mode (--run-degraded-coordination-e2e) that feeds real temporary Beads
state plus fixture-captured Agent Mail and RCH failures through the runpack
builder. The emitted evidence stays operator-only: it proves Beads soft-lock
fallback, degraded validation, and no cleanup/deletion-command output without
supporting release-facing speed or drop-in claims.
Fourth-wave swarm self-healing guidance layers a read-only stale-evidence
renewal queue, dry-run action plan, work admission gate, budget lease
simulation, turn pressure ledger, extension quarantine rehearsal, and redacted
handoff summaries onto that runpack flow. These artifacts can recommend
renew_stale_evidence, wait_for_pressure, use_beads_soft_lock, or similar
operator actions, but they do not mutate Beads, Agent Mail, extension
configuration, git, evidence files, RCH jobs, or release claims. The full
workflow and safe handoff wording live in
docs/swarm-operations-runbook.md#fourth-wave-self-healing-workflow.
The fourth-wave closeout gate emits
pi.swarm.fourth_wave_self_healing.closeout_gate.v1. It maps the
bd-63x3v.7 child Beads to implementation artifacts, contracts, fixtures,
operator docs, validation commands, pushed refs, source-boundary checks, and
remaining advisory limits. It is governed by
docs/contracts/fourth-wave-self-healing-closeout-gate-contract.json; the
current closeout artifact is
docs/evidence/fourth-wave-self-healing-closeout-gate.json.
Offline swarm replay traces can be previewed before handoff with
pi swarm-replay-preview --trace <trace.json> --format json. The command is
read-only, emits pi.swarm.replay_preview.v1 JSON or concise text, refuses to
overwrite requested output files, and can feed
scripts/build_swarm_operator_runpack.py --swarm-replay-preview-json <preview.json>
so runpacks carry the replay policy comparison without treating the runpack as
source-of-truth replay evidence. Operator workflow, privacy, and degraded-data
guidance lives in docs/swarm-replay-operator-workflow.md.
The autopilot closeout gate emits pi.swarm.autopilot_decision_gate.v1 to audit
the shipped input pack, planner, work partitions, failure actions, budget drift
watcher, E2E/logging evidence, runpack handoff, safety guards, pushed commits,
and quality gates before the swarm-autopilot epic is closed.
Context intelligence has its own operator guide and closeout gate. See
docs/context-intelligence.md for configuration,
preview workflows, failure modes, privacy posture, examples, troubleshooting,
and final closeout evidence. The context-intelligence closeout gate emits
pi.context_intelligence.closeout_gate.v1 and is governed by
docs/contracts/context-intelligence-closeout-gate-contract.json; the current
closeout artifact is docs/evidence/context-intelligence-closeout-gate.json.
The progress-SLO closeout gate emits pi.swarm.progress_slo.closeout_gate.v1.
It audits the shipped contract/source inventory, deterministic evaluator,
read-only CLI, Doctor/runpack projection, no-mock E2E evidence, large-host
stress budgets, operator docs, pushed child commits, source-boundary checks,
staged UBS, and Beads ledger reconciliation. It is governed by
docs/contracts/swarm-progress-slo-closeout-gate-contract.json; the current
closeout artifact is docs/evidence/swarm-progress-slo-closeout-gate.json.
The runtime-intelligence closeout gate emits
pi.runtime_intelligence.closeout_gate.v1. It maps the bd-h66tp child Beads
to compaction admission, tool-output artifacts, provider routing, scheduler
fairness, frame-budget telemetry, cancellation cleanup, extension safety
provenance, docs/evidence, source-boundary checks, pushed refs, and quality
gates. It is governed by
docs/contracts/runtime-intelligence-closeout-gate-contract.json; the current
artifact is docs/evidence/runtime-intelligence-closeout-gate.json. The gate
is advisory closeout evidence only and does not replace Beads, git, RCH, UBS,
CI, claim-integrity gates, or source artifacts.
The sixth-wave validation-hardening closeout gate emits
pi.swarm.validation_hardening.closeout_gate.v1. It maps the bd-63x3v.9
child Beads to RCH workspace-shadow detection, Agent Mail degraded Beads
soft-lock evidence, validation proof replay, temp artifact inventory, stale
claim heuristics, degraded-coordination E2E proof, cgroup/NUMA/RCH budget
modeling, provider/RPC/TUI backpressure budgets, operator explanations, pushed
refs, source-boundary checks, and quality gates. The provider/RPC/TUI contract
now includes a synthetic fairness stress gate for balanced load, one slow
provider stream, RPC output flood, and TUI frame-budget pressure, with fail-closed
negative controls when one surface reports success while another starves. It is governed by
docs/contracts/sixth-wave-validation-hardening-closeout-gate-contract.json;
the current artifact is
docs/evidence/sixth-wave-validation-hardening-closeout-gate.json. The gate is
advisory closeout evidence only and does not replace Beads, git, RCH, UBS, CI,
claim-integrity gates, or source artifacts.
The seventh-wave runtime-autonomy closeout gate emits
pi.swarm.runtime_autonomy.closeout_gate.v1. It maps the bd-63x3v.10
child Beads to effect-aware tool batching, fail-closed validation-proof reuse,
cgroup/NUMA lane placement, large-session replay acceleration, provider/RPC/TUI
fairness, work-admission dry-run execution, hostcall QoS starvation evidence,
source-boundary checks, pushed refs, and quality gates. It is governed by
docs/contracts/seventh-wave-runtime-autonomy-closeout-gate-contract.json; the
current artifact is
docs/evidence/seventh-wave-runtime-autonomy-closeout-gate.json. The gate is
advisory closeout evidence only and does not replace Beads, git, RCH, UBS, CI,
claim-integrity gates, child evidence, or source artifacts.
The proof-carrying swarm test-fabric closeout gate emits
pi.swarm.proof_carrying_test_fabric.closeout_gate.v1. It maps the bd-zeccr
child Beads to no-mock lifecycle E2E evidence, cross-surface conformance,
operator evidence goldens, structure-aware fuzz/property coverage, metamorphic
replay equivalence, source-boundary checks, pushed refs, negative controls, and
quality gates. It is governed by
docs/contracts/proof-carrying-swarm-test-fabric-closeout-gate-contract.json;
the current artifact is
docs/evidence/proof-carrying-swarm-test-fabric-closeout-gate.json. The gate is
advisory closeout evidence only and does not replace Beads, git, RCH, Agent
Mail, UBS, CI, claim-integrity gates, child evidence, or source artifacts.
The predictive-operations closeout gate emits
pi.swarm.predictive_operations.closeout_gate.v1. It maps the
bd-63x3v.11 child Beads to predictive telemetry fusion, RCH-aware validation
scheduling, semantic compaction quality, extension hostcall cost attribution,
operator-perceived latency, redundant-agent-work detection, source-boundary
checks, pushed refs, staged UBS, and Beads ledger reconciliation. It is
governed by
docs/contracts/predictive-operations-closeout-gate-contract.json; the current
artifact is docs/evidence/predictive-operations-closeout-gate.json. The gate
is advisory closeout evidence only and does not replace Beads, git, RCH, Agent
Mail, UBS, CI, claim-integrity gates, child evidence, or source artifacts.
The ninth-wave incident replay and proof-memory closeout gate emits
pi.swarm.incident_replay_proof_memory.closeout_gate.v1. It maps the
bd-9yq7i child Beads to incident corpus, incident replay, validation
proof-memory, operator work recommendation, operator smoothness SLO, extension
resource firewall matrix, and no-mock incident replay E2E evidence. It is
governed by
docs/contracts/ninth-wave-incident-replay-proof-memory-closeout-gate-contract.json;
the current artifact is
docs/evidence/ninth-wave-incident-replay-proof-memory-closeout-gate.json. The
gate is advisory closeout evidence only and does not replace Beads, git, RCH,
Agent Mail, UBS, CI, claim-integrity gates, child evidence, generated target/perf
outputs, prior-wave evidence, or source artifacts.
The closeout evidence registry at
docs/contracts/closeout-evidence-registry.json is the machine-readable index
of current advisory closeout-gate artifacts. It binds each current artifact to
its governing contract, decision schema, source bead or epic, Markdown
references, and advisory boundary, including current artifacts that are not
expanded above in prose: docs/evidence/adaptive-execution-closeout-gate.json,
docs/evidence/extension-compatibility-closeout-gate.json, and
docs/evidence/swarm-replay-closeout-gate.json. The registry is not a release
manifest, performance evidence bundle, Beads source of truth, Agent Mail
authority, RCH authority, CI/UBS replacement, drop-in certification gate, or
permission to delete or mutate files.
The operator-perceived latency trace emits
pi.operator.perceived_latency_trace.v1. It joins deterministic provider,
RPC, TUI, tool-update, and operator-visible fixture timelines so operators can
see when semantic output became visible while low-value updates were coalesced.
It is governed by
docs/contracts/operator-perceived-latency-trace-contract.json; the current
fixture artifact is docs/evidence/operator-perceived-latency-trace.json.
The trace is advisory only and does not authorize benchmark, capacity, release
performance, strict drop-in, or backpressure-budget replacement claims.
The operator smoothness SLO emits pi.operator.smoothness_slo.v1. It uses
deterministic high-volume fixtures for provider stream deltas, RPC output
pressure, TUI frame rendering, tool-update coalescing, and session-write
pressure. It is governed by
docs/contracts/operator-smoothness-slo-contract.json; the current fixture
artifact is docs/evidence/operator-smoothness-slo.json. Its p50/p95/p99
counters are engineering fixture counters only, proving semantic milestones
remain visible while low-value updates can be coalesced; they are not release
benchmark, capacity, performance, or strict drop-in evidence.
The extension resource firewall matrix emits pi.ext.resource_firewall_matrix.v1
from the deterministic extension stress fixture. It covers cheap-read floods,
large payload emission, denied capability churn, slow hostcalls, repeated
failure, and steady-peer progress while preserving payload redaction and
existing extension capability boundaries. The contract is
docs/contracts/extension-resource-firewall-matrix-contract.json; focused test
runs write resource_firewall_matrix.json under the configured target/perf
directory. This matrix is advisory stress evidence only and does not replace
runtime enforcement, hostcall cost attribution, RCH validation, Agent Mail,
Beads, UBS, CI, or benchmark/capacity/release claims.
The swarm incident corpus emits pi.swarm.incident_corpus.v1. It records
deterministic degraded-source fixtures for Agent Mail schema corruption, RCH
saturation with local-fallback denial, stale evidence, duplicate work risk,
dirty worktree admission denial, malformed sources, and deletion or live
mutation rejection. It is governed by
docs/contracts/swarm-incident-corpus-contract.json; the current fixture
artifact is docs/evidence/swarm-incident-corpus.json. The corpus is operator
evidence only and does not replace release performance, drop-in certification,
Agent Mail, RCH, Beads, git, source artifacts, or destructive-action authority.
The swarm incident replay harness emits pi.swarm.incident_replay.v1. It
consumes the checked-in incident corpus and replays healthy, degraded Agent Mail,
saturated RCH, duplicate work, stale evidence, malformed source, dirty worktree,
and deletion-request scenarios into ordered phases, per-step assertions,
redacted excerpts, selected safe actions, and follow-up recommendations. It is
governed by docs/contracts/swarm-incident-replay-contract.json; the cur
…(truncated)
GitHub checked 471h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.