Antigravity CLI provider: bounded tail latency - #13
Merged
Conversation
…licy The hook gets onRetry's blast-radius discipline plus the bound the backoff always had: return values clamp to [0, maxDelayMs], throwing or non-finite policies fall back to the exponential backoff.
…mpletion resample, doc truth-up Tier routing gets explicit effort-suffixed models (auto stays selectable), compile-time-tied to the catalog via AgyModelId; sunset gemini-3.5 ids migrate to the 3.7 line; empty completions resample with zero delay; the header documents the measured tool-catalog cost and the absence of any isolation mechanism. Standing registry/policy guards ship in-tree next to health-monitor.test.ts; one-shot behavioral proofs ride the PR description.
andreBurnt
force-pushed
the
fix/agy-latency-571
branch
from
September 1, 2026 22:59
d782433 to
34aef41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Antigravity CLI provider: bounded tail latency
Follow-up to #10. Routing tiers through
antigravity-cliruns 4.8s to 30s+ against sub-second direct-API equivalents. I benched the provider's exact argv against agy 1.1.23, fixed what is fixable client-side, and documented the rest where the next reader needs it. 2 commits, 3 files, +183/-31, no new dependencies.Tier defaults stop riding
autodefaultTierModelsnow maps every tier to an explicit effort-suffixed id: fast togemini-3.7-flash-low, balanced to-medium, smart and code to-high. The sharing is deliberate (the pro models reject--effortand pay pro latency, wrong for a tier default).autostays in the model list for anyone who wants it. Tier-routed calls resolve through the same map the ledger reports, so a tier never silently ridesauto. The map's values are compile-time-tied to the catalog (AgyModelId), so a typo'd id is a tsc error, not a runtime surprise.The measured basis, so you can check my reasoning. On a trivial prompt the floor is model-invariant:
autoran 2.82/3.04/3.19/3.05s over 4 runs,flash-lowran 2.74/2.97/3.08/3.40s over 4 runs plus one 4.71s outlier I cannot explain. The floor is process boot plus a 24.2k-token, 57-tool catalog prefill that never cache-hit across requests in any of my 15 single-turn runs (caching does work between turns inside one multi-turn call). On a hard prompt the arms diverge:autospent 725 and 773 thinking tokens (6.98s, 5.67s) whileflash-lowspent 0 and 504 (4.20s, 5.30s), 2 runs per arm. Small sample, consistent direction: explicit effort bounds the thinking budget,autopicks the high end on exactly the prompts that were already slow. I did not reproduce the 30s+ band in these runs. Its known ingredients (retry sleeps, multi-turn tool loops) are addressed or documented below.Empty completions resample instantly
An empty completion with SUCCESS status is the model abandoning the turn after a tool denial. It is stochastic, not load-shedding: identical requests varied from 0 to 568 thinking tokens in my probes. So waiting 1s/2s/4s between identical resamples was up to 7 dead seconds on the worst path.
RetryOptionsgains an optionaldelayMshook, and this provider returns 0 forEmptyCompletionErrorwhile transient CLI errors keep exponential backoff. Attempt cap unchanged at 3.On the shared-infra blast radius: every existing
withRetriescaller leavesdelayMsundefined and behaves exactly as before. The hook itself is clamped to[0, maxDelayMs]and wrapped likeonRetry. A future policy that throws or returns Infinity falls back to the plain backoff instead of crashing or sleeping forever. One design note:stream()keeps its own retry ladder becausewithRetriescannot wrap a generator. Both ladders now share the one policy function, which is as close as I could bring them without restructuring streaming.gemini-3.5 leaves the catalog because agy sunset it
The registry check in the new test file diffs
AGY_MODELSagainst liveagy modelsoutput. It failed on its first run: the 3.5 flash line no longer exists upstream. Removed here, withmodelMigrationscarrying saved 3.5 routings to the 3.7 line at the same effort. Same mechanism as the codexgpt-5/gpt-5-minitoautomigration atcodex-cli.ts:192.One test file ships in-tree, on purpose
I know the convention from #11 is lab scripts in the PR body, and the one-shot behavioral proofs are below as exactly that. But
antigravity-cli.test.ts(5 checks: tier map validity, resolution order, retry policy, migrations, live registry diff) is a standing guard, not a proof of this PR. It caught the 3.5 sunset the day it was written, and it will catch the day Google sunsets 3.7. As a PR-description script it runs once and rots. It follows thehealth-monitor.test.tsshape (node:test, zero deps) and the live check skips cleanly whenagyis not installed. If you want it out of the tree, onegit rmand it rides this description instead. My case is: this one earns its place.The header now says what I measured
57 tools and ~24.2k input tokens per request, never cache-hit across requests. No isolation mechanism in agy 1.1.23: no
--safe-modeor--config-dir,--sandboxdoes not shrink the catalog, config paths are hardcoded to~/.gemini/config/*. A HOME override forks agy's OAuth state, so I rejected it. And the sharpest one: headless sessions EXECUTE allow-ruled tools rather than denying them. My probes watchedrun_commandlist$HOMEandwrite_to_filecreate files (corralled in agy's per-sessionbrain/scratch). The header's "treat as a provider with tool access" warning was true before. Now it is specific.What this does not do
geminiprovider's job, and it already registers when a key credential exists.Evidence
npx tsc --noEmitclean. 13/13 across the suite: 3 in-tree health-monitor, 5 in-tree registry/policy guards, 5 lab checks below (pnpm tsx --test lab/*.test.ts, scripts kept in untrackedlab/per convention).Lab script 1 - RetryOptions.delayMs override behavior (3 checks)
Lab script 2 - instant-resample behavioral proofs with a stub agy (2 checks)