Exploring Pi Agent Harness: Extensible Terminal AI Agent
Discover Pi Agent Harness by earendil-works: a modular, self-extensible terminal AI agent with multi-provider LLM support and TS extensions.
In the landscape of AI coding assistants, most tools are built as monolithic “black boxes.” They lock developers into rigid workflows, predetermined UI layouts, and fixed plan modes. If you want to add a custom tool, tweak prompt handling, or integrate a specialized sandbox, you often have to wait for vendor updates or write fragile wrapper scripts.
Pi (@earendil-works/pi) reimagines this dynamic with a clear philosophy: Adapt the AI agent to your workflow, not the other way around.
[!NOTE] Pi is an open-source AI agent harness project developed by earendil-works (led by Mario Zechner / badlogic). Rather than bloated features, Pi provides clean, modular primitives for terminal-first AI development.
1. Explain Like I’m 10 (ELI5)#
Imagine buying a sports car where the hood is welded shut: you can’t swap the engine, change the dashboard, or attach custom sensors.
Pi Agent Harness is like a modular racing chassis:
- Engine Swap: Switch between Anthropic Claude, OpenAI, Google Gemini, DeepSeek, or local models via
llama.cppseamlessly. - Custom Dashboard: Build custom TypeScript extensions that render interactive terminal UIs or Q&A prompts.
- New Skills: Teach the agent project-specific workflows using Skills and Prompt Templates.
- Time-Travel Dashboard: Every interaction is stored in a tree-structured session file. If an approach fails, you can branch back to any previous step and try another path without losing history.
2. The 4-Layer Modular Architecture#
Pi is structured as four distinct npm packages, allowing developers to embed components into custom tools or use the full CLI directly:
┌─────────────────────────────────────────────────────────┐
│ @earendil-works/pi-coding-agent (CLI) │
├─────────────────────────────────────────────────────────┤
│ @earendil-works/pi-tui (Terminal UI) │
├─────────────────────────────────────────────────────────┤
│ @earendil-works/pi-agent-core (Agent Engine) │
├─────────────────────────────────────────────────────────┤
│ @earendil-works/pi-ai (Unified Provider API) │
└─────────────────────────────────────────────────────────┘text| Package | Purpose |
|---|---|
@earendil-works/pi-ai | A unified API layer wrapping over 30+ LLM providers (Anthropic, OpenAI, Google Gemini, DeepSeek, Bedrock, llama.cpp, etc.). |
@earendil-works/pi-agent-core | The core runtime managing tool calls (read, write, edit, bash), message history, agent loop, and context compaction. |
@earendil-works/pi-tui | A terminal UI library designed for high-performance differential rendering. |
@earendil-works/pi-coding-agent | The ready-to-use interactive CLI agent harness for your terminal. |
3. Core Features & Key Strengths#
Self-Extensibility via TypeScript#
Out of the box, Pi provides four fundamental tools to the model: read, write, edit, and bash. However, you can extend Pi without forking its internal codebase:
- Skills (
/skill:name): Modular task workflows defined in Markdown or TypeScript. - Extensions: Custom TypeScript modules adding interactive tools, status lines, or custom footers.
- Prompt Templates: Quick-expansion prompt macros accessible via
/template-name. - Pi Packages: Standard npm or git packages to distribute custom themes, skills, and extensions across teams.
Tree-Structured Sessions (/tree)#
Unlike linear chat logs, Pi records sessions in JSONL format as an acyclic tree structure (where each step tracks an id and parentId).
By using /tree in interactive mode, developers can visually navigate history, jump back to earlier prompt states, create branches, and filter messages.
[!TIP] Press
Ctrl+Owithin the/treeviewer to toggle view modes: full history, no-tool calls, user messages only, or bookmarked items.
Comprehensive Provider Support & Local LLMs#
Pi supports both API keys and subscription logins:
- Cloud Providers: Anthropic Claude, OpenAI, Google Gemini, DeepSeek, NVIDIA NIM, Groq, Mistral, OpenRouter, and more.
- Local Models: Native
llama.cpprouter support (/llama) for downloading, loading, and running GGUF models offline.
Flexible Containerization & Sandboxing#
Pi defaults to running with host user permissions. When executing untrusted code or automated tasks, Pi supports containerized execution via:
- Gondolin Micro-VM: Keeps
pion the host while routingbashcommands into a lightweight Linux VM. - Plain Docker: Runs the entire
piprocess in isolated containers. - OpenShell: Enforces fine-grained permission security policies.
4. Quick Start Guide#
Installation#
Install globally using npm:
npm install -g --ignore-scripts @earendil-works/pi-coding-agentbashOr via the official install script:
curl -fsSL https://pi.dev/install.sh | shbashLaunching & Provider Setup#
Set your API key and start the interactive CLI:
export ANTHROPIC_API_KEY=sk-ant-...
pibashUseful interactive commands:
/model: Select active LLM model (or pressCtrl+L)./login: Authenticate with subscription credentials./tree: Open the interactive session tree viewer./compact: Trigger manual context compaction./reload: Hot-reload keybindings, extensions, skills, and prompt templates.
5. Comparing Pi with OpenCode, Claude Code & Codex#
| Feature | Pi Agent (@earendil-works/pi) | Claude Code | OpenAI Codex | OpenCode |
|---|---|---|---|---|
| Philosophy | Unopinionated Harness (Self-extensible) | Opinionated Assistant (Tailored for Claude) | Dedicated Assistant (Tailored for OpenAI) | Modular Open-Source Framework |
| LLM Providers | 30+ Providers (Anthropic, OpenAI, Gemini, DeepSeek, llama.cpp) | Locked to Anthropic Ecosystem | Locked to OpenAI Ecosystem | Multi-provider (API keys/OpenRouter) |
| Session Management | Tree Sessions (/tree): Branching tree history with in-place rewinding | Linear chat history | Linear chat history | Standard session files |
| Extensibility | TypeScript Extensions, Skills, Prompt Templates, Pi Packages | Limited hooks & sub-agents | Basic Custom Instructions / Tools | Plugin architecture & Scheduler |
| Terminal UI | High-performance differential TUI (pi-tui) | Custom Terminal UI | Basic CLI | Terminal CLI |
| Integration Modes | 4 Modes: Interactive CLI, Print/JSON, RPC, Embeddable SDK | Standalone CLI | CLI / API | CLI / Framework |
| Sandboxing | Gondolin Micro-VM, Docker, OpenShell | Host / Docker Container | Host | Docker / Local |
6. Supporting Open-Source AI Research#
Pi encourages developers working on open-source projects to publish their coding session logs using badlogic/pi-share-hf. Real-world developer interactions help the community train better open models, refine prompt evaluations, and improve agent tooling.