@timmyjl12/pi-agy-bridge

pi provider for Google Antigravity (agy) models over the official ACP server, modelled on pi-claude-code: pi keeps the loop, history and tool execution

Packages

Package details

extension

Install @timmyjl12/pi-agy-bridge from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@timmyjl12/pi-agy-bridge
Package
@timmyjl12/pi-agy-bridge
Version
0.3.0
Published
Nov 24, 2026
Downloads
1,235/mo · 680/wk
Author
timmyjl12
License
MIT
Types
extension
Size
925.1 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-agy-bridge

Use Google Antigravity models (Gemini, Claude, GPT-OSS) in pi through the official agy acp server.

It follows the design of pi-claude-code: pi keeps the conversation, the approvals and the tool execution; agy is only the model. Every pi request becomes one ACP prompt turn. When the model wants a pi tool it writes a small tool-call block, pi runs the tool, and the next request carries the result. Nothing is parked between requests, so a slow tool (a long pytest run, a user dialog) can take as long as it needs and there is no turn time limit.

Status: 0.3.0. agy 1.5.16 and the google-antigravity SDK 0.1.24 are now tested. agy 1.5.16 retired gemini-pro-orchestrator-g1-pro; its orchestrators are now gemini-pro-orchestrator (Carbon), gemini-pro-orchestrator-argon and gemini-pro-orchestrator-neon, and Gemini 4 Carbon (low, medium, high) is new. The SDK change (a removed InputConfig.use_interactions_api field) does not touch the bridge, which uses the SDK only as a drift canary. Stalls and timeouts are now easier to diagnose: an extra account keeps its previous agy log as acp.prev.log, and with PI_AGY_TRACE=1 a stalled or timed-out turn records what agy last sent and when. agy 1.5.16 also forwards subagent and workflow questions to the editor; the bridge's carrier agent has no agy tools, subagents or skills, so agy never asks them here. 0.2.1: Extra-account sign-in works on agy 1.5.14: agy now prints a link and waits for the authorization code, so the bridge opens the link and asks for the code in a dialog. 0.2.0: Multiple Antigravity accounts: each extra account runs as its own provider agy-<alias or id> with its own login, managed from /agy-bridge menu or the /agy-bridge account commands; verified live on agy 1.5.14 with two Google accounts answering side by side. agy 1.5.14 is now tested: it refuses pi's appended system prompt silently (no notice for ~2 min), which auto now detects with a 30 s refusal probe and answers inline (see Multiple Antigravity accounts). 0.1.5: the default bridge home now honors Pi's configured agent directory (PI_CODING_AGENT_DIR). Every Pi session shutdown now recycles the outgoing runtime instead of permanently latching it shut, so a late pi-advisor retry can start a fresh ACP process; explicit terminal disposal remains terminal. The compatibility probe passed on agy 1.5.8, 1.5.9 and 1.5.12; the drift from 1.5.9 to 1.5.12 is additive only (the gemini-4-neon family, gemini-pro-orchestrator-neon, and xhigh as a thought_level). The google-antigravity SDK was then current at 0.1.23. On 2026-11-14 (agy 1.5.9) the Antigravity backend began refusing pi's default system prompt sent through the append hook with RESOURCE_EXHAUSTED; live gemini-4-hydrogen turns and pi-subagents runs succeed through the auto inline fallback (see PI_AGY_SYSTEM_PROMPT). Earlier live bridge checks passed on agy 1.5.8. Live turns succeeded on gemini-3.8-flash, gemini-4-hydrogen (including xhigh), and gemini-pro-orchestrator-g1-pro. A real pi surface check with the configured extensions also passed. Claude, GPT-OSS and the gemini-4-neon family have not been exercised in a live model turn.

Requirements

  • pi 1.5 or newer, Node 22.19 or newer
  • the Antigravity CLI agy 1.5.1 or newer, installed and logged in (run agy once and sign in)

Install

pi install npm:@timmyjl12/pi-agy-bridge

or try it for one run: pi -e npm:@timmyjl12/pi-agy-bridge. To develop on it, install a local checkout instead (pi install /path/to/pi-agy-bridge); keep only one of the two, or the provider registers twice.

Loading the extension starts nothing: no process, no network. The first request starts one shared agy acp process.

Use

Models appear as agy/<id> in /model:

Model Thinking levels
agy/gemini-4-argon, agy/gemini-4-carbon, agy/gemini-3.8-flash, agy/claude-opus-5-5, agy/claude-sonnet-5-5 low, medium, high
agy/gemini-4-hydrogen low, medium, high, xhigh (reported by agy 1.5.8)
agy/gemini-4-neon low, medium, high, xhigh (reported by agy 1.5.12)
agy/gemini-pro-orchestrator (Carbon), agy/gemini-pro-orchestrator-argon, agy/gemini-pro-orchestrator-neon no selectable reasoning level (agy 1.5.16; earlier releases called the Argon orchestrator gemini-pro-orchestrator-g1-pro)
agy/gpt-oss-120b-medium fixed (medium)

The list is what your agy reports, so new models appear without an update. pi's "off" thinking level is not offered because agy cannot switch thinking off.

Command What it does
/agy-bridge or /agy-bridge menu full-screen accounts & settings menu (same keys as pi-advisor: ↑↓ move, ←→ pane, Tab section, / search, Enter select, Esc back/close)
/agy-bridge status one line per account: sign-in state, agy version, process, pooled sessions
/agy-bridge doctor [id] handshake, compatibility with this package, features, models, process, hooks (no model call, no quota)
/agy-bridge reset [id|all] stop agy process(es) and forget pooled sessions
/agy-bridge accounts list accounts, providers and recorded Google accounts
/agy-bridge add <id> [alias] add an Antigravity account (then sign in)
/agy-bridge login <id> sign an extra account in, or switch it to another Google account
/agy-bridge alias <id> [alias] rename the provider to agy-<alias> (empty clears)
/agy-bridge email <id> [email] pin or clear the expected Google account by hand
/agy-bridge enable|disable <id> show or hide an account's models (its login is kept)
/agy-bridge remove <id> forget an account; asks before deleting its saved login
/agy-bridge check [id] / models [id] start an account once and list its models (no prompt, no quota)

Every menu entry has a command and vice versa. Arguments complete with Tab.

Multiple Antigravity accounts

agy keeps one login per OS user (on Windows the Credential Manager entry gemini:antigravity). An extra account gets its own folder, <PI_AGY_HOME>/accounts/<id>/, and its own agy acp process, started so that agy keeps that account's login in a file inside the folder instead of the shared keyring. pi lists it as a separate provider, agy-<alias or id>, with the models that account's plan offers:

/agy-bridge add acct2          # or: /agy-bridge menu → Add account
# your browser opens: sign in with the second Google account, then paste the
# authorization code (or the full URL of the page you land on) into pi's prompt
/agy-bridge accounts
agy                default    agy's own login     enabled
agy-acct2          acct2      timm…2385@gmail.com enabled
  • Sign-in on agy 1.5.14+. With a per-account token file agy no longer catches the browser redirect; it prints a link and waits for the code. The bridge opens that link (set PI_AGY_NO_BROWSER=1 to only show it), asks for the code in a dialog and passes it to agy. An empty answer cancels.

  • Your default account is unchanged. agy/<model> keeps using agy's normal login; without extra accounts this package behaves exactly as before.

  • Use them in fallback chains. A quota error on one account parks only that provider/model (pi-fallback-chains' per-model quota rule), so a chain can continue on the next account:

    "agy/claude-opus-5-5": ["agy-acct2/claude-opus-5-5", "agy/gemini-4-argon", "agy-acct2/gemini-4-argon"]

    Accounts on different plans offer different models: check with /agy-bridge models acct2 and only chain to models the account lists.

  • Wrong-account protection. Before an extra account serves a turn, agy's own log must show that it uses that account's token file and is signed in as the recorded Google account. Otherwise the turn fails with agy authentication required (not logged in) for account <id> (pi-fallback-chains does not retry it) and nothing is spent on another account. Errors of an extra account end with (account <id>).

  • Alias. /agy-bridge alias acct2 work renames the provider to agy-work; the folder stays accounts/acct2.

  • Settings. Accounts are stored in <PI_AGY_HOME>/accounts.json (id, alias, email, enabled: no credentials). PI_AGY_ACCOUNTS=acct2,acct3 adds accounts from the environment; PI_AGY_ACCOUNT_<ID>_EMAIL pins the expected Google account.

  • Cost. One more agy acp process per account while in use; each stops after PI_AGY_IDLE_MIN.

  • Terms. Whether using several Google accounts is allowed for your plans is your decision.

How it works: agy switches to per-folder token storage when it sees SSH_CONNECTION in its environment (measured on agy 1.5.12 and 1.5.14). The bridge sets that variable only on extra-account processes. It is not a documented agy option, so the free compat probe records it (fileTokenStorageTrigger) and reports breaking drift if a new agy stops honouring it; the wrong-account protection fails closed in that case.

Configuration

Environment variables (all optional). Invalid values fall back to the default.

Variable Default Meaning
PI_AGY_COMMAND / AGY_BIN agy the executable; a bare name is searched on PATH, then in the installer's default folder
PI_AGY_HOME ~/.pi/agent/pi-agy-bridge everything this package writes (see below)
PI_AGY_SILENCE_SEC 120 cancel a turn when agy sends nothing for this long (0 disables)
PI_AGY_SESSION_TTL_MIN 5 close an unused pooled session after this long
PI_AGY_TOOL_TTL_MIN 30 same, for a session whose turn ended at a tool call (pi is running the tool)
PI_AGY_MAX_SESSIONS 2 reusable sessions kept between turns
PI_AGY_IDLE_MIN 10 stop the agy process after this long without activity and with no pooled session
PI_AGY_CANCEL_GRACE_MS 3000 wait this long for a cancel before giving up on a turn
PI_AGY_MAX_REPLAY_KB 8192 refuse to replay a conversation larger than this
PI_AGY_CONTROL_TIMEOUT_SEC 60 timeout for handshake and session calls
PI_AGY_SYSTEM_PROMPT auto how pi's system prompt reaches agy: append (the session/new append hook), inline (top of the first prompt), or auto (append; if Antigravity refuses a fresh appended session with RESOURCE_EXHAUSTED before any output, retry that turn inline once and keep using inline). In auto the refusal is saved in <home>/state.json for 24 hours (or until agy's version changes), so other pi processes, including subagents, start inline without a refused attempt. agy 1.5.14 retries the refusal silently for about two minutes, so in auto a fresh appended session that shows no model output (text or thinking) within PI_AGY_REFUSAL_PROBE_SEC is treated as refused too
PI_AGY_REFUSAL_PROBE_SEC 30 auto only: seconds a fresh session with the appended system prompt may stay silent before it is retried inline (measured first output on agy 1.5.14: 0.4-3.4 s); 0 disables the probe
PI_AGY_TRACE off 1 appends diagnostics to <home>/trace.log, including, for a stalled or timed-out turn, how many updates agy sent, the kind of the last one and how long ago it arrived
PI_AGY_ACCOUNTS none extra accounts by id, comma-separated, in addition to accounts.json (see Multiple Antigravity accounts)
PI_AGY_ACCOUNT_<ID>_EMAIL none expected Google account of an extra account (normally recorded at sign-in)

pi's own request timeoutMs, when set, is honoured as a total deadline for the turn.

What is written to disk

Only under PI_AGY_HOME: the staged carrier agent (stage/), agy's private config root (gemini/), an empty working directory (work/), a small health hint (state.json), the account list (accounts.json), one folder per extra account (accounts/<id>/, holding that account's agy data, agy's log and the login agy saved there) and the optional trace. Nothing is written to your project, to ~/.gemini or to any global agy setting. Logins are only used: the bridge never reads, copies or forwards a token; it reads only agy's own log line that names the signed-in account.

Working with your other extensions

Extension Interaction
pi-context Shake, boundary compaction and rollover rewrite history without session_compact. This package registers in pi-context's rewrite registry and drops the affected pooled session, so the next turn replays the rewritten history. /fresh (pi-ai cleanupSessionResources) does the same. Usage follows agy's measured semantics: input is uncached input, cache reads are separate, reasoning is part of output; zero cache reads are reported as zero.
pi-fallback-chains Errors use phrases its classifier already knows (agy stalled for 120s with no output, agy spawn failed:, agy exited with status N, quota with agy's reset hint, not logged in, context_length_exceeded). Chains are keyed by model, so mirror your existing antigravity/* chains for agy/* when you switch (example below).
pi-subagents, pi-advisor, pi-fusion, pi-btw All share one agy process; each pi session has its own agy session, so concurrent callers never see each other's text. A cancelled or crashed turn does not affect the others.
pi-model-picker, pi-statusline Models carry names, context windows, a thinking map and zero list price. check answers from the file system and a small hint, so it never delays pi's start-up.
pi-todo, pi-ask-user and other tool extensions Their tools are listed to the model in the tool protocol and run by pi like any other tool.
pi-antigravity-bridge, pi-claude-code Independent: different provider id (agy), no shared state, private agy config root. Both can be loaded together.

Example chain, mirrored from an antigravity/* chain:

"agy/claude-opus-5-5": [
  { "model": "neuralwatt/kimi-k3-flex", "thinking_level": "max" },
  { "model": "agy/gemini-4-argon", "thinking_level": "high" },
  { "model": "agy/gemini-3.8-flash", "thinking_level": "high" }
]

Troubleshooting

Symptom Likely cause Fix
no agy/* models in /model agy not found, or the last use found it logged out or too old (hidden for 5 minutes) agy once to sign in, then /agy-bridge doctor (a successful run clears the hint)
agy authentication required (not logged in) login expired run agy and sign in
agy authentication required (not logged in) for account <id> that extra account has no saved login, or agy is signed in as a different Google account than the one recorded /agy-bridge login <id> (the new email becomes the expected one)
pi-agy-bridge is unavailable: agy did not switch to per-account token storage for account <id> an agy update stopped honouring the trigger extra accounts use; they fail closed rather than use your default login see UPGRADING.md §1 (the compat probe reports this as breaking)
agy quota exhausted: ... Resets in ... the plan's quota for that model is used up (agy delivers this as a normal reply with no tokens; the bridge turns it into an error so fallback chains rotate) use another model; the reset time is in the message
agy quota exceeded: Antigravity answered RESOURCE_EXHAUSTED ... the backend refused the request (429). agy would retry five times (~75 s); the bridge stops at the first notice. Since 2026-11-14 the backend refuses pi's default system prompt when it comes through the append hook (all models), while the same text inline is served; auto handles this nothing in auto mode; otherwise use another model. The message says whether the prompt was appended or inline
agy stalled for 120s with no output the model produced nothing for the silence limit (with agy 1.5.14 and PI_AGY_SYSTEM_PROMPT=append: the backend's silent refusal of the appended prompt; use auto) retry; raise PI_AGY_SILENCE_SEC for very long silent thinking. To see why, set PI_AGY_TRACE=1 (the trace names agy's last update); for an extra account agy's own log of the failed run is <home>/accounts/<id>/acp.prev.log after the next start
agy request timed out after 300s the turn hit pi's own request timeout (timeoutMs; 300 s here). agy's logs show its model request was still open: the backend kept the stream silent until the deadline, so this is a slow or stuck backend turn, not the bridge retry; the same PI_AGY_TRACE=1 line shows what agy last sent. The timeout itself is pi's setting, not the bridge's
agy exited with status N the agy process died retry (a new process starts); /agy-bridge doctor shows agy's last stderr
agy is unavailable: pi-agy-bridge is shut down during or just after reload/session replacement 0.1.2 or older permanently latched the outgoing pool while a background caller (often pi-advisor) was retrying upgrade to 0.1.3 or newer. An old advisor error can remain visible until a later review succeeds; that sticky status is normal
pi-agy-bridge is unavailable: agy ... below the minimum agy too old agy update
a notice that agy is newer-untested agy is newer than the tested matrix it keeps working; see UPGRADING.md

Known limits

  • agy's own tools (shell, file editing) are disabled on purpose: pi runs all tools. The model is told about pi's tools through a text protocol, so tool calls are as reliable as the model's JSON.
  • temperature, maxTokens and other sampling options cannot be sent through ACP and are ignored.
  • A tool-call block the model writes inside a Markdown code fence is still treated as a call (a text protocol cannot tell an example from a request); your approval settings in pi remain the safeguard. Tool output is shown to the model inside a code fence it cannot close and marked as data, not instructions.
  • agy does not report context windows, so every model defaults to 1M tokens (set deliberately; a window agy reports through usage_update.size replaces it). If a model's real limit is lower, agy answers context_length_exceeded, pi compacts and retries, and that one request is the cost.
  • A session is kept across tool calls: after pi runs a tool, the next request continues the same agy session and sends only the tool result (a session waiting for a tool is kept for PI_AGY_TOOL_TTL_MIN, default 30 minutes). If the session was dropped meanwhile (TTL, /fresh, a pi-context rewrite, a changed system prompt or tool set), history is replayed into a new session (about one extra second).
  • agy's prompt cache applies only to a continuing session and only above roughly 16k prompt tokens, so short conversations show no cache reads; real coding sessions cross that quickly.
  • The first request of a pi session starts the agy process (about one second). A running agy acp uses roughly 170 MB (measured idle on Windows, plus a conhost child) and stops after PI_AGY_IDLE_MIN minutes without activity.

Upgrading agy or the SDK

UPGRADING.md is the runbook: a free drift probe (npm run compat:probe), an SDK canary (npm run compat:sdk), and a compatibility matrix in compat/matrix.json.

Development

npm install
npm run check                      # tsc --noEmit
npm test                           # hermetic: fake agy, real sibling classifiers, no quota
$env:PI_AGY_LIVE = "1"; node --test tests/live.test.ts   # real agy, a few short Flash turns
node scripts/pi-rpc-check.mjs --surface                  # real pi + your packages (machine-specific paths)

See ARCHITECTURE.md for the design and NOTICE.md for credits (pi-claude-code and pi-antigravity-bridge, both MIT).