Pi (Rust): High-performance AI coding agent CLI written in Rust Pi (Rust), a high-performance AI coding agent CLI written in Rust, has been released as a port of the original Pi Agent. It offers instant startup, stable streaming, and a smaller memory footprint compared to Node.js or Python-based tools, with security features like capability-gated hostcalls and two-stage extension enforcement. The tool is designed for large-session, multi-agent, and extension-heavy workloads. pi agent rust - High-performance AI coding agent CLI written in Rust Why Should You Care? why-should-you-care • TL;DR tldr-piopenclaw-users • Methodology benchmark-methodology-and-claim-integrity • Quick Start quick-start • Features features • Installation installation • Commands commands • Configuration configuration Install latest release curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/pi agent rust/main/install.sh?$ date +%s " | bash You want an AI coding assistant in your terminal, but existing tools are: Slow to start : Node.js/Python runtimes add 500ms+ before you can type Memory hungry : Electron apps or heavy runtimes eat gigabytes Unreliable : Streaming breaks, sessions corrupt, tools fail silently Hard to extend : Closed ecosystems or complex plugin systems pi agent rust is a from-scratch Rust port of Pi Agent https://github.com/badlogic/pi by Mario Zechner https://github.com/badlogic made with his blessing . Single binary, instant startup, stable streaming, and 8 built-in tools. Rather than a direct line-by-line translation, this port builds on two purpose-built Rust libraries: : A structured concurrency async runtime with built-in HTTP, TLS, and SQLite asupersync https://github.com/Dicklesworthstone/asupersync : A Rust port of rich rust https://github.com/Dicklesworthstone/rich rust Rich https://github.com/Textualize/rich by Will McGugan https://github.com/willmcgugan , providing beautiful terminal output with markup syntax 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: Substantially faster in realistic end-to-end flows not synthetic microbenchmarks Dramatically smaller memory footprint in long-running sessions Materially stronger security model for extension/tool execution, including command-level blocking of dangerous extension shell patterns Security is a first-class design goal here, not a bolt-on: - Capability-gated hostcalls tool / exec / http / session / ui / events - Two-stage extension 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 policy - Policy + runtime risk + quota enforcement on the execution path - Per-extension trust lifecycle pending - acknowledged - trusted - killed with kill-switch audit logs and explicit operator provenance - Hostcall-lane emergency controls that can force compatibility-lane execution globally or for one extension when fast-lane behavior needs immediate containment - Structured concurrency via asupersync for more predictable cancellation/lifecycle behavior - Auditable runtime signals/ledgers and redacted security alerts for extension behavior The 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 report no CI no-data or 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 | | Deterministic hostcall reactor mesh shard affinity, bounded SPSC lanes, backpressure telemetry, optional NUMA slab tracking | Runtime behavior stays predictable under contention; queue pressure and routing decisions are observable instead of opaque | | Startup prewarm + warm isolate reuse for JS runtimes | Runtime creation overlaps startup and warm reuse keeps repeated extension runs low-latency without a Node/Bun process model | 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 . All numeric performance claims in this README include inline citations with format: from artifact-path , run correlation-id Example: from artifact-path , run correlation-id CI checks both file freshness and artifact content so stale, no-data, or correlation-mismatched evidence cannot back user-facing performance claims. The README evidence checker reports line-numbered proof obligations for cited claims and extracts claim-gated performance phrases for reviewer audit. Explicit 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 speed gains come from runtime design, not one trick. | Technique | What we do | Runtime effect | |---|---|---| | Cold-start minimization | Single static binary, no Node/Bun runtime bootstrap, no JIT warmup, startup prewarm for extension runtime paths | Faster 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 | Lower CPU and allocation pressure | | Deterministic dispatch core | Typed hostcall opcodes, fast-lane/compat-lane routing, bounded shard queues with reactor-mesh telemetry | Better tail latency under concurrent extension load | | Efficient long-session storage | SQLite session index + v2 sidecar segmented log + offset index with O index+tail reopen path | Fast resume on large histories | | Streaming parser tuned for real networks | SSE parser tracks scanned bytes, handles UTF-8 tails, normalizes chunk boundaries, interns event-type strings | Lower streaming overhead and fewer parser stalls | | Safe fast-path controls | Shadow dual execution sampling, automatic backoff on divergence/overhead, compatibility-lane kill switches for containment | Keeps optimizations fast without silent behavior drift | | CI-level performance governance | Scenario matrices, strict artifact contracts, fail-closed perf gates | Regressions are caught before release | If you want the full implementation inventory, see Performance Engineering performance-engineering . The benchmark evidence policy is designed to keep results realistic, reproducible, and hard to game. What we measured: Matched-state workloads : resume a large session and append the same 10 messages. Realistic E2E workloads : resume + append + extension activity + slash-style state changes + forks + exports + compactions. Scale levels : from 100k up to 5M token-class session states. Startup/readiness : command-level readiness --help , --version separately from long-session workflows. How we kept comparisons fair: Two scopes in the benchmark report:- apples-to-apples pi agent rust vs legacy coding-agent - apples-to-oranges legacy stack components included where legacy behavior is outsourced - apples-to-apples Release-mode binaries and repeated runs per matrix cell. No paid-provider noise in core latency/footprint tables provider-call costs are excluded from these core comparisons . How we kept claims honest: Security controls stayed on during secure-path measurements no policy/risk/quota bypasses for speed claims . Raw artifacts are preserved JSON/trace/time outputs and called out in the benchmark report. Blockers are explicitly disclosed : when direct legacy reruns were blocked by missing workspace deps, we state that and compare against prior validated legacy artifacts instead of pretending reruns succeeded. Interpretation notes are explicit : the report distinguishes baseline sections vs fresh reruns so readers can see exactly which values came from which run set. Reproducibility over marketing : methodology, caveats, and known limits are included alongside wins. 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 | <100ms | 500ms-2s | Binary size | ~21.1 MiB default release | 100MB+ with runtime | Memory idle | <50MB | 200MB+ | 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 https://github.com/Dicklesworthstone/asupersync is a structured concurrency async runtime designed for applications that need predictable resource cleanup. Key features used by pi agent rust: Capability-based context : Async functions receive an explicit context that controls what they can do HTTP, filesystem, time . This makes testing deterministic. Cx HTTP client with TLS : Built-in HTTP API with rustls, avoiding OpenSSL dependency hell Structured cancellation : When a parent task cancels, all child tasks cancel cleanly. No orphaned futures. 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 https://github.com/Dicklesworthstone/rich rust is a Rust port of Will McGugan's Rich https://github.com/Textualize/rich Python library. It provides: Markup syntax : bold red error / renders as bold red text Tables : ASCII/Unicode table rendering with alignment and borders Panels : Boxed content with titles Progress bars : Animated progress indicators Markdown : Terminal-rendered markdown with syntax highlighting Themes : Consistent color schemes across components The terminal UI uses rich rust for all output formatting, providing the same visual quality as Rich-based Python tools. 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?" Real-time token streaming with extended thinking support: pi "Write a quicksort implementation" Watch the response appear token-by-token, with thinking blocks shown inline. | Tool | Description | Example | |---|---|---| read | Read file contents, supports images | Read src/main.rs | write | Create or overwrite files | Write a new config file | edit | Surgical string replacement | Fix the typo on line 42 | hashline edit | Precise edits using LINE HASH tags | Apply edits to specific lines using hashline anchors | bash | Execute shell commands with timeout | Run the test suite | grep | Search file contents with context | Find all TODO comments | find | Discover files by pattern | Find all .rs files | ls | List directory contents | What's in src/? | All tools include: - Automatic truncation for large outputs 2000 lines / 1MB - Detailed metadata in responses - Process tree cleanup for bash no orphaned processes 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: - Tree structure for conversation branching - Model/thinking level change tracking - Automatic compaction for long conversations Enable deep reasoning for complex problems: pi --thinking high "Design a distributed rate limiter" Thinking levels: off , minimal , low , medium , high , xhigh Skills : Drop SKILL.md under ~/.pi/agent/skills/ or .pi/skills/ and invoke with /skill:name . Prompt templates : Markdown files under ~/.pi/agent/prompts/ or .pi/prompts/ ; invoke via /