OpenCode 2 vs Pi Agent (1.0 & Durable): Which Coding Agent Wins?
Hands-on comparison of OpenCode 2 and Pi 1.0 (+ Pi Durable): background daemon, subagents, and desktop app vs Codemode, native MCP, and crash-safe state.
Updated Published 13 min read

I have been running OpenCode and Pi side by side for months. Both are open-source terminal coding agents, both connect to cheap open-weight models, and both run happily on a $6/month VPS. Earlier this year the comparison was simple: OpenCode was the batteries-included TUI, and Pi was the four-tool minimalist harness.
Then both projects shipped massive rewrites. OpenCode 2.0 moved to a persistent background daemon with built-in sub-agents, git worktrees, and a desktop/web client. Pi 1.0 (now under Earendil, built by Mario Zechner and Armin Ronacher) reversed its long-standing “no MCP” stance with a QuickJS sandbox called Codemode and shipped Pi Durable for crash-safe, always-on background agents.
I still keep both installed, and the split between them is sharper now than it was at launch. Here is what changed and how they compare today.
What this covers
- What changed in OpenCode 2.0 (daemon, sub-agents, Code Mode, desktop/web pairing) and Pi 1.0 + Pi Durable
- Daemon architecture vs Pi Durable’s SQLite/JSONL crash recovery
- Updated install commands (
@opencode/cliv2 and@earendil-works/pi-coding-agent) - How both solved MCP context bloat with programmable sandboxes
- Pricing with GLM-5.3, MiniMax M3.1 Flash, DeepSeek V4.1, and OpenCode Go (31 models)
For step-by-step setup, see the OpenCode setup guide and the Pi coding agent setup guide.
What changed in late 2026: OpenCode 2.0 and Pi 1.0
If you read older comparisons of these two tools, half the bullet points are now wrong.
- OpenCode 2.0 became a background daemon. Rewritten in TypeScript and Effect, OpenCode 2 runs a local daemon (port
49374on Linux/macOS/WSL,45278on Windows). Your terminal TUI, the beta Desktop App, the Web UI (opencode pair), and@opencode/sdkscripts all attach to the same running service. - OpenCode 2 added sub-agents and git worktrees. Version 1 had no sub-agents. Version 2 ships
@general,@explore, and@scoutsub-agents that run asynchronously in the background, plus git worktree isolation so parallel tasks do not wreck your current checkout. - Pi 1.0 added native MCP via Codemode. For over a year, Pi refused to build MCP into core because raw JSON tool schemas bloated the prompt. On October 1, 2026, Pi 1.0 solved that with Codemode: a QuickJS sandbox where the model writes short JavaScript snippets to call, filter, and parallelize MCP tools without dumping raw outputs into the chat transcript.
- Pi Durable (
@earendil-works/pi-durable) shipped alongside Pi 1.0. It checkpoints every model turn, tool call, and compaction step to SQLite, JSONL, or Cloudflare Durable Objects. If a container restarts or your VPS reboots mid-task, the process resumes from the exact save point with idempotency checks on tool replay. - Pi moved to
@earendil-works/pi-coding-agent. The repo lives atearendil-works/piand requires Node.js 22.19+.
Philosophy: shared daemon workspace vs programmable harness
Even after both updates, the core split holds.
OpenCode 2 wants to be your complete coding environment across terminal, browser, and desktop. You install it, run /connect, and immediately have build and plan agents (toggle with Tab), @explore sub-agents, /init, /undo, image drag-and-drop, and remote pairing (opencode pair --remote). You do not write TypeScript to make it useful.
Pi 1.0 still starts small—read, write, edit, bash, a fullscreen TUI, and Codemode—and expects you to shape it. Want persistent Markdown memory, custom bash guards, or a specialized review loop? You drop .ts files into ~/.pi/agent/extensions/. And if you are building your own background agent daemon or multi-tenant bot instead of using an off-the-shelf UI, Pi Durable gives you the state machine and crash-recovery primitives as an npm library.
Installation
Note the new v2 URLs for OpenCode and the new @earendil-works package scope for Pi 1.0 (which now requires Node.js 22.19+).
OpenCode 2
curl -fsSL https://opencode.ai/v2/install | bashIf you are upgrading an existing v1 install, run opencode upgrade --major (v1 and v2 share the opencode binary name). You can also install via npm (npm i -g @opencode/cli@latest), Homebrew (brew install anomalyco/tap/opencode-v2), or Docker:
docker run -it --rm ghcr.io/anomalyco/opencode:2.0.0Pi 1.0 & Pi Durable
The recommended install for the Pi 1.0 CLI is the official script:
curl -fsSL https://pi.dev/install.sh | shOr via npm, Bun, or Nix:
# npm (requires Node.js 22.19+)
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
# Nix
nix profile add github:earendil-works/pi/stableIf you are building a crash-safe background service or custom agent app with Pi Durable, install the SDK packages into your TypeScript project:
npm install @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/chordArchitecture: OpenCode 2 Daemon vs Pi Durable
This is the most interesting technical difference between the two in late 2026. Both teams realized that a coding agent tied to a single interactive TTY dies the moment your SSH pipe drops or your laptop sleeps—but they solved it from opposite ends.
How OpenCode 2’s daemon works
When you launch opencode, it starts a background daemon listening locally on port 49374 (or 45278 on Windows). Every interface is just a client talking to that service:
- Start a refactor in the terminal TUI
- Run
opencode pairto open the same live session in the Web UI or the beta Desktop App (macOS, Windows, Linux) - Use
opencode pair --remoteto create an end-to-end encrypted tunnel protected by a server password so you can check on a home server or VPS session from another machine - Drive the daemon programmatically with
@opencode/clientand@opencode/sdk
How Pi Durable works
Pi kept the pi CLI as a clean interactive terminal runner and broke out long-running state into @earendil-works/pi-durable.
Instead of a single local desktop daemon, Pi Durable is an execution engine for agents that must survive process crashes, containerredeploys, or server reboots:
- Task-level checkpointing: Every LLM call, tool execution, and context compaction is committed as a discrete step to SQLite, JSONL, or Cloudflare Durable Objects.
- Exact crash recovery: If your worker process gets killed mid-turn, a new process opens the SQLite/JSONL store and picks up right where the interrupted step stopped.
- Replay safety (idempotency): When recovering from a crash, you do not want an agent to blindly re-run a
git push, a database migration, or a Stripe charge. Pi Durable makes tools declare whether they are safe to auto-replay. Idempotent read tools re-run automatically; non-idempotent tools surface the interrupted state back to the model so it can inspect what happened before acting.
If you want a ready-made multi-client app you can pair with your browser today, OpenCode 2’s daemon wins. If you are writing your own always-on DevOps or coding bots in TypeScript and need transactional state recovery, Pi Durable is built for that job.
Model support
Both agents connect to the same cheap open-weight models.
OpenCode 2
OpenCode supports 75+ providers through Models.dev and local engines like Ollama and LM Studio. Set your keys in .env or run /connect in the TUI.
Keep provider API keys in local env vars
On October 17, 2026, OpenCode disclosed a breach of its legacy Console system that exposed stored third-party API keys (OpenAI, Anthropic, Google) for ~1.4% of Console users. Store your provider keys locally in ~/.config/opencode/.env or environment variables rather than saving raw production keys inside third-party web dashboards.
Pi 1.0
Pi supports 20+ built-in providers plus custom endpoints in ~/.pi/agent/models.json (which hot-reloads when you open /model). Pi 1.0 also added virtual models for router-style model switching and deferred tool loading.
Both agents work out of the box with OpenRouter and OpenCode Go. The OpenCode Go plan now includes 31 models for $10/month (plus a $40/month Go Plus tier with 2–4x higher limits), covering GPT 6 Luna, GLM-5.3, DeepSeek V4.1 Flash, Kimi K3, MiniMax M3, and Qwen 3.8. See the best cheap models guide and the OpenCode Go review for exact 5-hour request caps.
Models I run with both agents (Late 2026)
| Task | Model | Typical API Cost |
|---|---|---|
| High-volume everyday edits | GLM-5.3-Flash / MiniMax M3.1-Flash | $0.15/M input |
| Fast agentic coding & tools | DeepSeek V4.1 Flash | Included in Go ($80 cap) |
| Hard multi-file refactors | GLM-5.3 | $1.40/M input |
| Long-context repo surgery | DeepSeek V4 Pro / Kimi K3.1 Pro | $0.435–$2.00/M input |
Workflow comparison
Plan mode
OpenCode 2 has plan and build as primary agents. Press Tab to switch between read-only planning and active file editing.
Pi still keeps planning modular through the pi-plan extension (or LazyPi), giving you read-only planning and approval gates once installed.
Code Mode vs Codemode: how both fixed MCP bloat
This is a funny convergence: both projects shipped almost the exact same solution to MCP’s biggest flaw and even gave it nearly identical names.
Connecting 30 MCP tools the traditional way dumps thousands of lines of JSON schema into your system prompt before you type a word. Both agents now bypass that:
- OpenCode 2 “Code Mode”: Exposes connected MCP servers and tools as programmable JavaScript functions so the agent can chain and compose multiple operations in a single pass instead of burning tokens on back-and-forth tool turns.
- Pi 1.0 “Codemode”: Runs a harness-side QuickJS sandbox. Native MCP is now built into Pi 1.0 core (no
pi-mcp-adapterrequired), and the model writes short JS scripts inside the sandbox to call MCP tools in parallel, filter the data locally, and return only the compact result to the conversation.
Sub-agents and parallel work
OpenCode 2 closed the gap here. You get built-in sub-agents—@general, @explore, and @scout—that the primary agent delegates to automatically or that you can invoke with @mentions. Combined with OpenCode 2’s git worktree support, background tasks and builds run asynchronously without locking your terminal.
Pi handles parallel agents through pi-subagents and its extension API, or at the infrastructure level via @earendil-works/pi-durable and @earendil-works/chord when orchestrating multi-agent graphs in code.
Memory
OpenCode 2 still relies on AGENTS.md for static project rules and MCP memory servers (like Hindsight or Cognee) if you want cross-session recall.
Pi uses the pi-memory-md extension to read and write persistent Markdown notes about your repo automatically across sessions, while Pi Durable persists full execution checkpoints to SQLite or JSONL.
Sessions and CLI automation
OpenCode 2 gives you /undo, /redo, /share, session syncing across TUI/Web/Desktop via the local daemon, and opencode pair.
Pi gives you /resume, /new, /tree, /fork, and /clone to branch conversations like git history, plus pi -p "prompt" with --mode json or --mode rpc for CI pipelines and shell scripts.
Extensions and SDKs
OpenCode 2 (@opencode/sdk)
OpenCode 2 introduced official programmatic packages—@opencode/client and @opencode/sdk—that talk to the v2 daemon over its local HTTP/WebSocket API. Note that because v2 was a ground-up rewrite in Effect, legacy v1 plugins had breaking changes.
Pi 1.0 (~/.pi/agent/extensions/ + pi-durable)
Pi’s TypeScript extension system remains the easiest way to hack on your own interactive agent: drop a .ts file into ~/.pi/agent/extensions/, intercept tool calls, add slash commands or custom TUI widgets, and run /reload. LazyPi still installs 60+ skills and 76 themes in one shot, and pi-config provides ready-made bash guards and web tools.
Pricing
Both agents are free, MIT/open-source software. You only pay for model tokens.
| Setup | Monthly Cost |
|---|---|
| GLM-5.3-Flash / MiniMax M3.1-Flash (API) | $2–8/month typical use |
| OpenCode Go (31 models, works in both) | $10/month ($40/mo Go Plus) |
| GLM-5.3 / DeepSeek V4 Pro (direct or OpenRouter) | $10–25/month |
| Claude Sonnet / Opus via Anthropic API | $20–60+/month |
One OpenCode Go key works in both OpenCode 2 and Pi 1.0 (export OPENCODE_API_KEY=your-key).
Side-by-side summary (OpenCode 2 vs Pi 1.0)
| Feature | OpenCode 2.0 | Pi 1.0 (+ Pi Durable) |
|---|---|---|
| Core architecture | Persistent local daemon (port 49374) |
Minimal CLI harness + optional @earendil-works/pi-durable |
| Install package | @opencode/cli (opencode.ai/v2/install) |
@earendil-works/pi-coding-agent (pi.dev/install.sh) |
| UI surfaces | Fullscreen TUI, Web UI, Desktop App (beta) | Fullscreen TUI, JSON/RPC headless modes |
| Plan mode | Built-in (Tab between plan and build) |
Via pi-plan extension |
| MCP support | Built-in with JS Code Mode | Built-in native MCP with QuickJS Codemode |
| Sub-agents | Built-in (@general, @explore, @scout) + git worktrees |
Via pi-subagents extension or @earendil-works/chord |
| Crash-safe state | Daemon session persistence | Pi Durable (SQLite / JSONL / Cloudflare DO + replay safety) |
| Model providers | 75+ built-in | 20+ built-in + hot-reloading models.json + virtual models |
/init bootstrap |
Built-in (AGENTS.md) |
Manual AGENTS.md or pi-config |
| Customization | Config, MCP, @opencode/sdk |
Hot-reload .ts extensions + 76 themes |
| OpenCode Go support | Yes (31 models) | Yes (31 models) |
When to pick OpenCode 2
- You want a complete system right after install with zero extension hunting
- You like starting a task in the terminal and checking it in a browser or desktop window via
opencode pair - You want built-in
@exploreand@generalsub-agents with git worktree isolation - You want
/init,/undo,/redo, and 75+ pre-wired providers out of the box
When to pick Pi 1.0 (and Pi Durable)
- You want a fast, minimal terminal agent where every extra behavior is a readable
.tsfile you control - You like Pi 1.0’s QuickJS Codemode for chaining MCP tools without context bloat
- You use conversation branching (
/tree,/fork,/clone) and headlesspi -pscripting - You are building your own long-running background agents or multi-user bots and need Pi Durable’s SQLite checkpointing and idempotent tool recovery
When to use both
I still run both on the same VPS. OpenCode 2 is my default when I want the plan -> build loop, background @explore sub-agents, or opencode pair --remote into a browser tab. Pi 1.0 is what I reach for when I want a stripped-down terminal session with custom .ts extensions, or when I am wiring up a durable background workflow that cannot afford to lose state on a restart. Both share the same OPENCODE_API_KEY and OPENROUTER_API_KEY.
Can I use the same API key for both OpenCode 2 and Pi 1.0?
Yes. Both read OPENROUTER_API_KEY and OPENCODE_API_KEY from your environment. One $10/month OpenCode Go subscription works across both tools and shares the same 5-hour and weekly allowance.
What is Pi Durable and do I need it for normal CLI coding?
No—if you just run pi interactively in your terminal, the standard @earendil-works/pi-coding-agent CLI already saves and resumes your chat transcripts. Pi Durable (@earendil-works/pi-durable) is for developers building long-running background agents, daemons, or web apps where the agent must survive process crashes or server reboots and safely replay or skip interrupted tool calls.
How do I upgrade from OpenCode v1 to OpenCode 2?
Run opencode upgrade --major or install directly with curl -fsSL https://opencode.ai/v2/install | bash. Because v1 and v2 both use the opencode binary name, v2 replaces v1 in your PATH. If you used v1 custom plugins, check them after upgrading since the v2 Effect rewrite introduced breaking API changes.
Did Pi 1.0 really add native MCP support?
Yes. After resisting MCP for over a year due to schema token bloat, Pi 1.0 added native MCP support on October 1, 2026 via Codemode. Instead of dumping every MCP schema into the prompt, the model writes JavaScript inside a QuickJS sandbox to call and filter MCP tools locally.
Can I run both on the same VPS?
Yes. OpenCode 2 runs its background daemon on port 49374 by default, while Pi runs as a standalone process in your directory. They do not conflict.
For more agent guides, see the Hermes Agent setup guide, the GitHub Copilot alternatives article, and the best open source models for OpenClaw guide. For the wider tooling catalog, see 60+ top AI GitHub repos.


