provider-antigravity
v0.3.1POC llm-router provider `antigravity` that drives the Antigravity CLI (`agy acp`, Agent Client Protocol) on the host, reusing agy's own sign-in; the caller's functions reach the model as native tools.
Install
iii call compose::add worker=provider-antigravity@nextRun in your project with the iii engine running. Exact versions are immutable and digest-pinned.
provider-antigravity (POC)
An llm-router provider, antigravity, that answers chat turns by driving the
Antigravity CLI (agy) over the
Agent Client Protocol (agy acp), reusing
agy's own sign-in. Its models show up in the console's model picker like any
API-key provider. (This worker was formerly provider-acp.)
This is the client side of ACP: iii drives agy. The acp worker is the server
side: an editor drives iii.
Setup
Do these on the machine where the worker runs (the host, not the computer you open the ADE from).
Install the Antigravity CLI (macOS and Linux):
curl -fsSL https://antigravity.google/cli/install.sh | bash agy --versionThe installer puts agy in
~/.local/bin/agy, where the worker finds it.agy installsets upPATHand the shell afterwards. Installed elsewhere: set the agy path in Settings > Antigravity, orAGY_BIN. Install docs.Sign in with your Google account, in a terminal:
agy acp --loginOver SSH (no browser on that machine), it prints a URL: open it in your own browser, sign in, and paste the code it gives you back into the terminal. The credentials go to the OS keyring. To sign out, run
/logoutinsideagy. Sign-in docs.Instead of an account:
- Gemini API key: set
"modelProvider": "gemini"in~/.gemini/antigravity-cli/settings.jsonand exportGEMINI_API_KEYin the worker's environment, then restart the worker. The key alone does nothing. - Application Default Credentials:
gcloud auth application-default login --project <PROJECT>, thenAGY_ADC_AUTH=truefor the worker (optionallyGOOGLE_CLOUD_QUOTA_PROJECT,GOOGLE_CLOUD_LOCATION).
- Gemini API key: set
Add the worker to the stack (see Run).
The ADE guides the same steps: Settings > Antigravity and Manage models > Antigravity (CLI) > Configure show a checklist (installed, signed in, models available) for the worker's host, with the commands to copy and a Check again button.
How it works
Catalog.
agy modelslists one id per model and effort (gemini-4-neon-high). The provider folds them into one model per family, as agy's own switcher does, and publishes them asantigravity/<family>withreasoning_efforts. The console's effort picker then works:- the turn's
thinking_levelselects the agy id<family>-<effort>, sent withsession/set_model; - no level, or a level the family lacks, falls back to
high.
antigravity/defaultkeeps agy's own configured model. Exact agy ids (antigravity/gemini-4-neon-low) still work. A turn that finds no catalog for the current binary lists the models first; if that listing fails, a family id fails the turn with the listing error.- the turn's
Turns. Each router call starts
agy acpin a fresh, empty temp directory and runs one ACP session:initialize;session/new, with the system prompt in_meta.antigravity.systemPrompt.append;session/set_model;- one
session/promptcarrying the conversation, flattened into one user message. A line of the caller's text that could pass for a role, call, result, image or file marker gets a\ahead of it; other lines stay as written. Names and ids inside a marker lose their line breaks.
agent_message_chunkupdates stream as router text,agent_thought_chunkupdates as thinking, and the prompt'susagebecomes the turn's usage.Function calling is native. The caller's functions are declared as tools of a stub MCP server named
iii, so the model calls them with real structured arguments. agy launches the stub as this same binary,provider-antigravity mcp-stub <tools.json>, with the tool list written to the turn's workspace. Bus ids are encoded asengine__workers__list; ids that encode alike get_2,_3. The stub never runs anything.- A
.agents/hooks.jsonPreToolUsehook in the workspace denies every tool call before it runs. - Each blocked call to an
iiitool becomes a routerfunction_call, with agy'stoolSummarystripped unless the function declares it. - 300 ms after the last call of a batch, the client sends
session/cancel, so the model never spends a step reacting to the block.
The turn then ends with
stop_reason: function_call. The caller (the harness, with its policy, approvals, transcript and traces) runs the calls and sends the results in the next turn's history.- A
agy's own tools stay blocked. The hook blocks them too. Any
session/request_permissionis refused, as a second layer. Attempts show up aswarningson the message.Environment. agy gets an allowlisted environment (see Run), so no
III_*variables reach it.Errors.
Failure Router error_kindQuota reached (usage limit) rate_limitedwitherror_details.usage_limit, not retried by the router429 or rate limit rate_limitedAuth failure auth_expiredagy dies before answering transient, retried by the routerAny other error agy answers with permanentThe text is written for the chat user. A missing agy says the Antigravity CLI is not installed on
<host>, with the install command and the agy path setting. An auth failure says it is not signed in on<host>, with<agy path> acp --login. agy's own message follows as the detail.agy's quota texts ("Individual quota reached", "You have exhausted your quota on this model.", "Usage limit reached", "Quota exhausted"), and a
stopReasonthat names the quota, are the account's usage limit, even when the text also carries a 429: oneerrorframe of kindrate_limitedwitherror_details {usage_limit: true, window?, resets_at_ms?}, which the router does not retry. The window and reset come from the last quota reading (see Quota): the spent bucket of the turn's model group. Without one, there is no window or reset. The text readsAntigravity usage limit reached (<group>). Resets at <RFC 3339 time>., then agy's own message. The failure also starts a quota reading.stopReason: max_tokensends the turn withstop_reason: length.Abort. The router's
abort(keyed byresolution_key), a closed channel (seen at the next frame or keep-alive ping, at most 25s) or a worker shutdown kills agy's process group: SIGTERM first, then SIGKILL after 3s.Images. Each image block, including those inside function results, stays as an
[image N]marker in the flattened text. The image itself goes after the conversation as an ACP image block, behind a matching[image N]text block. The catalog setssupports_visionon every model except agy's text-onlygpt-oss, which drops images without an error.Context windows. These are the sizes agy reports in ACP
usage_update: 1,048,576 tokens for Gemini, 1,000,000 for Claude and 131,072 forgpt-oss.agy modelsdoes not list them, so the worker sets them by family name, and an unknown family gets the smallest.input_limitsubtracts the 64k output budget and 20k for agy's own system prompt and tool schemas, which measured 10.7k to 19k tokens on a one-word prompt.Unsupported request fields.
response_formatis not passed to agy.Cost. Every router call is a fresh agy process and session given the full flattened history. Each round trip of a tool loop therefore pays agy's start-up (about 2s for
session/new) before the model runs.
Quota
ACP has no quota method, so the worker runs agy usage --json (read-only,
about 3 s, needs the network). It reports agy's limits per model group,
"Gemini Models" and "Claude and GPT models" (bucket ids gemini-* and
3p-*). Each group has a five-hour and a weekly window, with the fraction left
and the reset time (none while the window is idle).
- How it runs. Like
agy models: the allowlisted environment, its own process group, killed after 15 s or on shutdown. - When. The worker keeps one reading and reads in the background, one read
at a time.
statusstarts a read when there is none or it is over 5 minutes old. Check again and a turn that hit the quota start one when the last is over a minute old or failed. - Which group a turn spends. The Gemini group when the model id starts with
gemini, or isdefault(agy's default is a Gemini model). Otherwise the Claude and GPT group.
Run
Requires an installed, signed-in agy (Setup) on the same machine.
Without agy the worker still starts and registers its functions; turns then
fail with the install instructions, and the setup screen shows step 1 as not
done.
cargo run --release -- --url ws://127.0.0.1:49134iii.worker.yaml gives a supervisor the same thing: cargo build --release,
then ./target/release/provider-antigravity. Stop it with SIGINT or SIGTERM:
it aborts the turns in flight, waits up to 5s for them to report, and exits
within 8s.
Build
cargo build --release
cargo fmt --all -- --check
cargo clippy --locked --all-targets --all-features -- -D warnings
cargo test --locked --all-featuresThe release binary is the whole artifact: the worker, the MCP stub
(mcp-stub subcommand) and the ADE screen (assets/, embedded at build time).
Published builds cover macOS and Linux only, where agy runs.
--url sets the engine URL. Without it: III_URL, then III_ENGINE_URL,
then ws://127.0.0.1:49134.
| Env var | Purpose |
|---|---|
AGY_BIN |
agy binary, used when the saved agy_bin setting is empty. Default: ~/.local/bin/agy, then agy on PATH |
III_CONFIG_NAME |
id of the configuration entry. Compose sets it (<namespace>-provider-antigravity); default provider-antigravity |
III_URL |
engine URL when --url is not given. Compose sets it |
III_ENGINE_URL |
engine URL when neither --url nor III_URL is given |
RUST_LOG |
log filter. Default info |
agy runs with only these variables from the worker's environment:
| Passed to agy | Why |
|---|---|
HOME, PATH, USER, LOGNAME, SHELL, TERM, TMPDIR, LANG, LC_ALL, LC_CTYPE, XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME, XDG_RUNTIME_DIR |
Home, locale, temp |
DBUS_SESSION_BUS_ADDRESS |
The keyring on Linux (Secret Service over D-Bus), where agy keeps its sign-in |
GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL |
Gemini API key sign-in |
AGY_ADC_AUTH, GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, GOOGLE_CLOUD_QUOTA_PROJECT, GOOGLE_APPLICATION_CREDENTIALS |
Application Default Credentials sign-in |
The worker must run on the host (path:// in compose, no base_image) so it
can reach agy and its sign-in (the keyring and ~/.gemini).
Configuration
The worker creates a configuration entry named Antigravity, with
metadata.ui_form: provider-antigravity, through configuration::ensure (a
stored value is kept). It holds one setting:
| Key | Default | Purpose |
|---|---|---|
agy_bin |
"" |
Absolute path of the agy binary. Empty: AGY_BIN, then ~/.local/bin/agy, then agy on PATH. A non-empty value wins over AGY_BIN. |
A save applies with no restart. The worker observes configuration::on-updated
for its entry, re-reads the value, and re-lists the models with the new binary.
The binary is resolved on every turn and listing. If the configuration worker
does not answer at start, the worker runs on AGY_BIN and the defaults and
retries in the background (1 s, doubling to 30 s) until it answers, then applies
the saved value with no restart.
The worker injects one ADE stylesheet and one script through
iii-console-ui (provider-antigravity::ui-content behind the
ade::ui::asset observers). Both are hand-written files in assets/,
embedded in the binary, so there is no frontend build. The script registers
two forms, both led by the same setup checklist for the worker's host:
- Install the Antigravity CLI: done when agy runs (path, where it came from, version). Otherwise the install command, with a Copy button.
- Sign in: done when agy has proved it is signed in. Otherwise
<agy path> acp --login, the SSH flow, and the API key and ADC alternatives. Waits for step 1. - Models available: done when the models are listed and registered with llm-router. Otherwise the listing error or the last turn error.
Below the checklist, once agy is installed, signed in and its quota read, a Quota section shows each model group's 5-hour and weekly limit: the share left as a bar, the reset time and when it was read, or why the read failed.
- Settings > Antigravity: the checklist, then the optional
agy_binfield (Advanced) and the model list. The ADE owns the draft, validation and Save. - Manage models > Antigravity (CLI) > Configure: the same checklist, read-only, with a link to the Settings entry. It replaces the router's generic API endpoint form.
The screen never runs a command or signs in for you: it shows the commands to run in a terminal on the worker's host, then Check again re-lists the models. Copy needs a secure origin; over plain http the command stays selectable.
Two bus functions back the screen:
| Function | Returns |
|---|---|
provider::antigravity::status |
host (the worker's hostname), the binary (path, source, agy --version, error), signed_in, sign-in hints, model count, listing error, registration, last turn error, the sign-in command, and quota. It runs agy --version, starts a background agy usage when the quota reading is missing or stale, and never returns a token or key value. signed_in comes from the current binary's last model listing or a newer turn's auth failure: null when unknown. |
provider::antigravity::refresh_models |
{count}, after re-listing the models and re-registering with llm-router. A failed listing keeps the previous models and shows in status. It also starts a quota reading. Denied to agents. |
status.quota is the current binary's last quota reading, null
until there is one: {read_at_ms, bin, groups: [{name, buckets: [{id, window: "five_hour" | "week", remaining_fraction, resets_at_ms}]}], error}.
resets_at_ms is null while the window is idle. A failed read has no groups
and agy's error (a signed-out agy says how to sign in). An answer without a
five-hour or weekly limit is a failed read.
The sign-in hints in status.credentials follow the Antigravity docs. They only
describe how agy may be signed in; signed_in is the truth.
| Hint | True when |
|---|---|
token_file |
~/.gemini/antigravity-cli/antigravity-oauth-token exists (never read) |
api_key |
settings.json there has "modelProvider": "gemini" (only that key is read) and GEMINI_API_KEY is set for the worker |
adc |
AGY_ADC_AUTH=true for the worker |
Security
- The ADE on
0.0.0.0has no auth: anyone who reaches it can open these screens and the rest of the console. - The agy path setting is a code-execution route: whoever can save it picks the binary the worker runs on every turn and listing. Keep the ADE off untrusted networks.
Code
src/main.rs: the CLI, boot order and shutdown.src/acp.rs: the ACP transport (one turn against a freshagy acp).src/mcp_stub.rs: the stub MCP server that declares the caller's functions.src/antigravity.rs: agy specifics (binary, environment, models, efforts, errors, quota, probe, session cleanup).src/prompt.rs: the conversation flattened into one ACP prompt, and the host instructions.src/frames.rs: router stream frames.src/provider.rs: llm-router plumbing,status,refresh_modelsand the quota reading.src/configuration.rs,src/ui.rs,assets/: the setting and the ADE screens.tests/fixtures/:fake-agy.mjsandfake-agy-signed-out.mjs, test doubles of agy,agy-usage.json, a realagy usage --jsonanswer (agy 1.5.22), andrender-page.mjs, which renders the served page fortests/ui.rs(the scripts need Node).