pi for Go

A pure-Go port of pi's multi-provider LLM API, agent loop and coding agent — no Node.js runtime required.

Source repo
sky-valley/pi
Stars
★ 93
Last updated
3d ago
FARS reviewed
Dec 01, 2026
License
MIT
Primary language
Go

At a glance

Works with
Universal · cross-platformOpenAI API · Claude API
You'll need
Go toolchainProvider API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, …)Shell / CLINetwork accessLocal filesystem
Typical use
Go shops that want to embed a coding agent in an existing service by importing github.com/sky-valley/pi/coding, without shipping a Node.js runtime.
Main limitation
The interactive TUI, the host/mode layer driving it, the extensions runtime and the trust prompt/store are explicitly not ported; this port is headless.
Maintenance
Commits in the last 30 dayslast commit 2026-11-28+0.5 ★/day over 7 days

What does this agent do, and when should you use it?

This repository is a pure-Go port of Mario Zechner's pi (earendil-works/pi): the @earendil-works/pi-ai unified streaming API, the pi-agent-core agent loop, and the pi-coding-agent CLI, rewritten natively in Go with no Node.js process at runtime. It is split along upstream package lines into ai, ai/providers, agent, coding and cmd/pi, plus a separately versioned env module and a difftest module that diffs request bodies against real pi. At runtime a CLI invocation or SDK call resolves a model, opens a session, and the agent loop consumes SSE deltas through a channel-based EventStream, executing built-in tools sequentially or in parallel. Built-in tools are read, write, edit, bash, powershell, ls, find and grep, and sessions persist as append-only JSONL under ~/.pi/agent/sessions/. Four real wire APIs — Anthropic Messages, OpenAI Chat Completions, OpenAI Responses and Google Gemini — plus a deterministic faux provider cover roughly 816 of the catalog models.

A pi invocation takes a prompt, coding.ResolveModel picks a model from the embedded catalog, and coding.NewSession builds the session. agent.AgentLoop runs the turn lifecycle, handing requests to providers registered via ai.RegisterApiProvider, which issue net/http SSE calls and parse streamed deltas. Text deltas, tool calls and usage are surfaced as agent.AgentEvent values (for example ai.EventTextDelta) to subscribers. During tool phases the loop runs read/write/edit/bash/powershell/ls/find/grep, feeds results back into the conversation, and continues until a terminate signal or a stop reason. The coding package assembles AGENTS.md, AGENTS.override.md, CLAUDE.md and .pi/skills/*/SKILL.md into the system prompt, scanning project skills only when SessionOptions.TrustProject is set. Sessions are written as JSONL to ~/.pi/agent/sessions/--<cwd>--/, resumable with -c or --resume PATH. The env module's ConnectSSH deploys a daemon to a remote host and RemoteExecutionEnv runs files, commands and terminals through it.

  1. Go shops that want to embed a coding agent in an existing service by importing github.com/sky-valley/pi/coding, without shipping a Node.js runtime.
  2. Developers doing one-shot or multi-turn terminal work, e.g. pi -m anthropic/claude-opus-4-5 "..." or pi -m openai/gpt-5 --think high "...".
  3. Integrators who need to inspect or rewrite outgoing request payloads and headers via coding.SessionOptions.OnPayload, plus retry and compaction settings.
  4. Teams that want auditable, resumable agent transcripts: JSONL sessions on disk, -c continuation, and coding.LoadSessionTree + LoadBranch for projections.
  5. Automation that must run commands and terminals on a remote host over SSH without installing Node or Rust on either end.

Key setup facts

Pulled from the install and usage notes below. The project README has the current values.

Environment variables
ANTHROPIC_API_KEY OPENAI_API_KEY GEMINI_API_KEY

How do you install or deploy this agent?

Install a Go toolchain, then build from source and run the test suite:

go build ./...
go test ./...          # race-clean; live-API tests skip without keys
go build -o pi ./cmd/pi

For library use, fetch the main module; the remote execution environment is a separate module with its own tags:

go get github.com/sky-valley/pi
go get github.com/sky-valley/pi/env

At least one provider key must be present in the environment before first run:

export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export GEMINI_API_KEY=...

How do you use this agent?

Start with print mode, then drop into the REPL or manage sessions:

pi "explain what this repo does"
pi
pi -m anthropic/claude-opus-4-5 "refactor foo.go"
pi -m openai/gpt-5 --think high "..."
pi --think high "refactor foo.go"
pi -c "and now add tests"
pi models claude
pi sessions

Embed it via the SDK facade; coding.NewSession returns a structured RunResult and Subscribe streams events:

model, _ := coding.ResolveModel("openai/gpt-5")
sess, err := coding.NewSession(coding.SessionOptions{
    Model:         model,
    ToolNames:     []string{"read", "bash"},
    ThinkingLevel: agent.ThinkHigh,
    SessionID:     "chat-42",
    MaxRetries:    4,
})
res, err := sess.Run(ctx, "refactor foo.go and add a test")

Using ai alone requires a blank import so providers self-register:

import _ "github.com/sky-valley/pi/ai/providers"

Sessions hold no API key; to inject one explicitly, configure runtime credentials on the model runtime with coding.NewRuntimeCredentials and credentials.SetRuntimeApiKey. A runnable example lives in examples/sdk/main.go.

Safety boundaries, hardening & integrations

Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.

Declared capability surface (blast radius)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

FARS trust-control audit

Verified present in source (3/3)
  • verifiable attribution
Not found in source — apply before daily use
  • confirmation before acting — Turn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.

What are this agent's strengths and limitations?

Pros
  • Genuinely Node-free: providers, agent loop, tools and the SSH env daemon are all Go, so it can ship in the same process or image as an existing Go service.
  • Concrete multi-provider coverage: four real wire APIs (Anthropic Messages, OpenAI Chat Completions, OpenAI Responses, Google Gemini) reach roughly 816 catalog models, with a deterministic faux provider for tests.
  • Fidelity is testable, not asserted: difftest/ captures the HTTP request body real pi builds and the one this port builds for identical inputs, canonicalizes both, and diffs them.
  • Wide SDK surface: tool allow/deny/custom tools, thinking-level clamping, temperature, maxTokens, headers, retries honoring Retry-After, onPayload/onResponse, and auto context compaction, with aggregated usage and cost in RunResult.
  • On-disk compatibility: append-only JSONL sessions, -c continuation, --resume PATH, and branch loading reuse the same layout as upstream.
Limitations
  • The interactive TUI, the host/mode layer driving it, the extensions runtime and the trust prompt/store are explicitly not ported; this port is headless.
  • AWS Bedrock (SigV4 + eventstream framing) and OpenAI Codex (WebSocket + zstd) are out of scope for now, and OAuth token acquisition, Azure Responses, and Mistral/Vertex/Radius adapters are still queued.
  • Because there is no UI to prompt with, project-local .pi/skills are not scanned unless you opt in with SessionOptions.TrustProject.
  • You must build the binary yourself with a Go toolchain, and every run still needs your own provider API key with per-token billing.
  • Catalog size is stated inconsistently (a 999-model catalog in the project description vs. 1,599 chat models across 42 providers in the body), so verify actual model availability before relying on it.

How does this agent compare with similar options?

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
pi for Go This agent 63 · Some gaps — ★ 93 3d ago Go OpenAI API · Claude API
AgentForge 55 · Major gaps CLIFree + model costs ★ 67 10d ago Python OpenAI API · Claude API
ai4j — Java AI Agentic SDK 60 · Some gaps Library / SDKFree + model costs ★ 443 today Java OpenAI API · Claude API
PI from Scratch 56 · Major gaps CLIFree + model costs ★ 1.3k 1mo ago TypeScript OpenAI API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Some gaps
63/ 100 5-point scale 3.2 / 5
Trust 13/29
Reliability 8/14
Adaptability 14/18
Convention 14/18
Effectiveness 9/13
Verifiability 5/8
Why each dimension lost points
Trust13 / 29 · 2.2/5

Evidence: the README states project-local .pi/skills are not scanned unless SessionOptions.TrustProject is set, which is a genuine least-privilege control, and it documents client identity (User-Agent, OpenRouter/NVIDIA/OpenCode attribution headers), env-var key resolution, and that a session holds no API key. Deductions are concrete: the built-in bash/powershell/write/edit tools execute with no sandbox and no approval path anywhere in cmd/pi/main.go (user_confirmation = 0); the env module deploys a daemon onto remote hosts; sessions persist as plaintext JSONL under ~/.pi/agent/sessions/ with no redaction or permission note; env/bin embeds prebuilt daemon binaries that, despite a sha256 manifest and the gendaemons builder, cannot be confirmed reproducible from static evidence. source_attribution = 3: LICENSE keeps both Sky Valley and upstream Mario Zechner copyright, and README plus difftest explicitly name upstream pi as ground truth.

Reliability8 / 14 · 2.9/5

Evidence: go.mod depends only on golang.org/x/image and golang.org/x/text, a very small surface; requireProviderAuth in main.go emits specific env-var guidance (including Cloudflare account/gateway ids) and model-restore failures warn explicitly, so failure messages are actionable. Deduction: the description says a '999-model catalog' while the README says '1,599 chat models across 42 providers' and elsewhere '~816 of pi's 999 catalog models' — the model-count claim contradicts itself within the same packet (self_consistency = 1). env is a separate module requiring its own go get, and its embedded binaries are tied to a Go version, so dependency availability is only adequate.

Adaptability14 / 18 · 3.9/5

Evidence: the README Layout table maps ai/agent/coding/cmd/env onto upstream packages and gives both CLI usage and an SDK embedding example, covering Go shops, SDK embedders and CLI users. capability_boundaries = 3 because the 'Not yet ported' section explicitly lists the TUI, extensions runtime, Bedrock, Codex, OAuth, Azure Responses and Mistral/Vertex/Radius. Deductions: trigger_precision is limited because the product is an explicitly invoked CLI/library with no trigger-condition or scope mechanism; environment_fit is only adequate — pure Go with no Node runtime and multi-platform daemons is good, but go 1.26 plus embedded binaries impose constraints and no compatibility matrix is given.

Convention14 / 18 · 3.9/5

Evidence: the README is well structured (layout table, build/test, usage, SDK, fidelity notes, license), LICENSE is full MIT with upstream copyright, and known_limitations = 3 thanks to the explicit unported list and difftest 'Known limits'. Deductions: install_notes cover only go build/go test and go get, with no versioned install or release-artifact instructions; examples_and_faq has examples/sdk and README snippets but no FAQ; versioning_changelog relies on docs/releases/vX.Y.Z.md and release.yml but ships no CHANGELOG; maintenance_responsibility is weakened by the unverified publisher, and the maintenance process (daily pi-sync, ledger) lives in contributor skills as process description rather than a verifiable commitment.

Effectiveness9 / 13 · 3.5/5

Evidence: RunResult returns structured text, tool calls, messages, stop reason and aggregated usage/cost, Subscribe streams events, and sessions persist/resume as JSONL — adequate for ordinary use. Deductions: as a Go port of upstream pi, the marginal value is mainly removing the Node runtime, which is limited for non-Go teams; on cost_benefit, embedding eight-platform daemons and a 1,599-model catalog inflates the artifact, and no performance or cost comparison is provided, so only a middle score is justified.

Verifiability5 / 8 · 3.1/5

Evidence: fidelity claims cite concrete upstream files and commits (agent-loop.ts, sdk.ts:359-361, a9424cd43), difftest/ provides a byte-level request-body differential against real pi, and the skills define a parity review against the npm build — claim_traceability and cross_source_corroboration have real support. Deductions: several 'line-for-line' / 'match pi exactly' statements are assertions with no differential run output or baseline report in the packet, and fact_inference_separation suffers because the README interleaves verified results with planned work (OAuth, Azure 'in scope and queued') in the same paragraph, leaving readers to separate fact from plan; all three scored 2.

Risks and how to mitigate them
  • Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
  • The built-in bash/powershell/write/edit tools run without a sandbox or per-call confirmation, and the env module can deploy a daemon to a remote host; isolate before use on untrusted repositories or hosts.
  • Sessions persist as plaintext JSONL under ~/.pi/agent/sessions/ and may contain prompts, code fragments and tool output; no redaction or file-permission handling is documented.
  • env/bin embeds prebuilt daemon binaries; despite a sha256 manifest and builder script, static review cannot confirm reproducible builds — rebuild from source before relying on them.
  • The model-catalog count is inconsistent between the description (999) and the README (1,599 across 42 providers); verify against the embedded catalog before sizing or cost estimates.
  • Publisher identity is unverified; maintenance commitments and update cadence can only be inferred from contributor skills and the release workflow, not treated as enterprise support.
  • File writes and command execution have no rollback; session resume restores conversation state only and does not undo filesystem or remote side effects.
Evidence confidence: Low Reviewed Dec 01, 2026 Reviewed revision d6891c52d3fe
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/sky-valley-pi.svg)](https://followagents.com/en/agents/sky-valley-pi)
<a href="https://followagents.com/en/agents/sky-valley-pi"><img src="https://followagents.com/badge/sky-valley-pi.svg" alt="FARS review"></a>
Was this page helpful?
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts