Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(antigravity): resolve ids in the availability check like the transport
Jack Rudenko8452d275c566
diff --git a/ai-docs/architecture/providers/antigravity.md b/ai-docs/architecture/providers/antigravity.mdindex da9fe550..97f6fc26 100644--- a/ai-docs/architecture/providers/antigravity.md+++ b/ai-docs/architecture/providers/antigravity.md@@ -171,6 +171,26 @@ past the subscription to a metered provider.Routing is unchanged: `resolveAntigravityModelId` and the transport resolveagainst the full `servedIds`, so a typed `[email protected]` still works.+**The availability check resolves ids the way the transport does** (2026-10-21,+`ai-docs/reports/model-failures-2026-10-21.md` D8). `providerServesModel` used to+match the requested id exactly against the dynamic models catalog, because+Antigravity has no entry in the resolver registry. On an account serving only+`gemini-3.8-flash-tiered`, `[email protected]` therefore read as not served and+`--advisor` refused it, while the transport would have sent the tiered variant; a+bare `gemini-3.8-flash` lost its `ag@` hop the same way and went to a metered+provider. The transport, the credential and the check now share one function,+`resolveAntigravityServedModel` (`transport/antigravity.ts`):+`resolveAntigravityModelId` with the cloud models catalog's family default+(`lookupFamilyDefaultVariant`). The check feeds it the transport's own inputs, the+full `servedIds` and the backend's `defaultAgentModelId`, from the `getServedAntigravityModels` cache+the discovery just filled (`peekServedAntigravityModels`), and then asks whether+the resolved id is in the dynamic models catalog. An id the backend declares+unselectable therefore still reads as not served. With no cache (a fetch that+never succeeded under this client version) it resolves against the dynamic models+catalog's ids with no backend default. Antigravity stays out of the resolver+registry: a resolver there receives neither the full `servedIds` nor the backend+default.+## Ordering: cloud models catalog dates are poison for Antigravity's modelsAntigravity rows set `ignoreCatalogReleaseDate`. `compareByReleaseDateDesc` sortsdiff --git a/packages/cli/src/auth/antigravity-user.ts b/packages/cli/src/auth/antigravity-user.tsindex 92426168..453b328b 100644--- a/packages/cli/src/auth/antigravity-user.ts+++ b/packages/cli/src/auth/antigravity-user.ts@@ -644,6 +644,20 @@ export async function getServedAntigravityModels(return { servedIds: [], defaultId: null, meta: {} };}+/**+ * The `servedIds` and `defaultId` the last fetch cached under this process's client version,+ * without fetching; null when there is none. For the routing availability+ * check (`providerServesModel`), which runs right after discovery fetched this+ * set and must resolve against the same `servedIds` and `defaultId` the+ * transport resolves against (`resolveAntigravityServedModel`). The discovery+ * list it also reads has the backend's unselectable ids removed, so it cannot+ * stand in for them.+ */+export function peekServedAntigravityModels(): AntigravityServedModels | null {+ if (!agServedCache || agServedCacheVersion !== antigravityClientVersion()) return null;+ return agServedCache;+}+/** Test seam: clear the Antigravity served-models cache between tests. */export function _resetAntigravityServedModelsCache(): void {agServedCache = null;diff --git a/packages/cli/src/auth/credentials/antigravity-credential.ts b/packages/cli/src/auth/credentials/antigravity-credential.tsindex 4c84589b..213b840a 100644--- a/packages/cli/src/auth/credentials/antigravity-credential.ts+++ b/packages/cli/src/auth/credentials/antigravity-credential.ts@@ -7,7 +7,7 @@* - the identity is ALWAYS Antigravity (antigravity UA + ideType ANTIGRAVITY),* independent of CLAUDISH_GEMINI_ANTIGRAVITY;* - the requested model id is resolved to a LIVE-served id- * (resolveAntigravityModelId over getServedAntigravityModels) before it goes+ * (resolveAntigravityServedModel over getServedAntigravityModels) before it goes* into the CodeAssist envelope.** Request artifact:@@ -22,8 +22,7 @@*/import { randomUUID } from "node:crypto";-import { lookupFamilyDefaultVariant } from "../../adapters/model-catalog.js";-import { resolveAntigravityModelId } from "../../providers/transport/antigravity.js";+import { resolveAntigravityServedModel } from "../../providers/transport/antigravity.js";import {getValidAntigravityAccessToken,readSharedAntigravityToken,@@ -86,12 +85,9 @@ export class AntigravityCredentialProvider implements CredentialProvider {const { projectId, tierId } = await setupAntigravityUser(token);// Resolve the requested id against the account's dynamic models catalog// (fetchAvailableModels).- const { servedIds, defaultId } = await getServedAntigravityModels(token, projectId);- const servedModel = resolveAntigravityModelId(+ const servedModel = resolveAntigravityServedModel(ctx.model,- servedIds,- defaultId,- lookupFamilyDefaultVariant(ctx.model, "antigravity")+ await getServedAntigravityModels(token, projectId));return {headers: {diff --git a/packages/cli/src/providers/model-availability.ts b/packages/cli/src/providers/model-availability.tsindex 5e75f686..7b1aecd8 100644--- a/packages/cli/src/providers/model-availability.ts+++ b/packages/cli/src/providers/model-availability.ts@@ -91,12 +91,33 @@ function modelsCatalogHas(ids: string[], wireId: string): boolean {* with the request's real effort when it sends. For a provider with no* resolver, `expandSelection` returns `wireId` unchanged, so their answer is* exactly what it was.+ *+ * Antigravity resolves outside the resolver registry (see its comment there)+ * and the same rule applies: `[email protected]` read as not served on an+ * account serving only `gemini-3.8-flash-tiered`, which the transport sends,+ * so a bare name lost its subscription hop. It resolves here with the+ * transport's own function over the transport's own inputs: the full served+ * set and the backend's default id, cached by the discovery that just ran.+ * Only when that cache is absent does it fall back to the dynamic models+ * catalog's ids with no backend default. Loaded lazily, so no other provider's+ * check pulls in the Antigravity transport.*/-function resolveAgainstModelsCatalog(+async function resolveAgainstModelsCatalog(provider: string,wireId: string,models: DiscoveredModel[]-): string {+): Promise<string> {+ if (provider === "antigravity") {+ const [{ resolveAntigravityServedModel }, { peekServedAntigravityModels }] = await Promise.all([+ import("./transport/antigravity.js"),+ import("../auth/antigravity-user.js"),+ ]);+ const served = peekServedAntigravityModels() ?? {+ servedIds: models.map((m) => m.id),+ defaultId: null,+ };+ return resolveAntigravityServedModel(wireId, served);+ }const entries = models.map(({ id, ...rest }) => ({ wireId: id, ...rest }));return expandSelection(provider, wireId, entries);}@@ -127,7 +148,7 @@ export async function providerServesModel(if (models.length > 0) {return modelsCatalogHas(models.map((m) => m.id),- resolveAgainstModelsCatalog(provider, wireId, models)+ await resolveAgainstModelsCatalog(provider, wireId, models))? "serves": "not-served";diff --git a/packages/cli/src/providers/model-resolvers/registry.ts b/packages/cli/src/providers/model-resolvers/registry.tsindex 8a98de15..7b0e3579 100644--- a/packages/cli/src/providers/model-resolvers/registry.ts+++ b/packages/cli/src/providers/model-resolvers/registry.ts@@ -26,6 +26,11 @@ import type {* adopting it would mean either regressing that rule or redesigning the seam's* context type. Its rule stays in `transport/antigravity.ts`; folding it in is a* follow-up, not a merge-time decision.+ *+ * The routing availability check still resolves Antigravity ids exactly as its+ * transport does: `providerServesModel` calls `resolveAntigravityServedModel`+ * with the transport's own inputs (the full `servedIds` and the backend's+ * `defaultAgentModelId`), which a resolver here could not receive either.*/const RESOLVERS: ProviderModelResolver[] = [new DevinModelResolver()];diff --git a/packages/cli/src/providers/transport/antigravity.ts b/packages/cli/src/providers/transport/antigravity.tsindex 0c04b11c..e6a5d782 100644--- a/packages/cli/src/providers/transport/antigravity.ts+++ b/packages/cli/src/providers/transport/antigravity.ts@@ -192,6 +192,29 @@ export function resolveAntigravityModelId(return req;}+/**+ * The id a request for `requested` is SENT as: {@link resolveAntigravityModelId}+ * over the account's full dynamic models catalog (`servedIds`), with the cloud models catalog's family default+ * (`lookupFamilyDefaultVariant`) as its second rule.+ *+ * The ONE resolution the transport, the credential (which builds the primary+ * envelope) and the routing availability check (`providerServesModel`) share.+ * The check used to match the requested id exactly, so `[email protected]`+ * read as not served on an account serving only `gemini-3.8-flash-tiered`,+ * which the transport would have sent, and a bare name lost its `ag@` hop.+ */+export function resolveAntigravityServedModel(+ requested: string,+ served: { servedIds: string[]; defaultId: string | null }+): string {+ return resolveAntigravityModelId(+ requested,+ served.servedIds,+ served.defaultId,+ lookupFamilyDefaultVariant(requested, "antigravity")+ );+}+/** Generate a short random request ID (matches the Antigravity CLI activity logger) */function createActivityRequestId(): string {return Math.random().toString(36).substring(7);@@ -346,9 +369,6 @@ export class AntigravityProviderTransport implements ProviderTransport {*/private servedModels: string[] = [];- /** The backend-provided default served model id (from fetchAvailableModels). */- private defaultServedModel: string | null = null;-constructor(modelName: string) {this.modelName = modelName;// Resolved against the account's dynamic models catalog in refreshAuth();@@ -431,15 +451,10 @@ export class AntigravityProviderTransport implements ProviderTransport {// reflect what THIS subscription actually serves today.const served = await getServedAntigravityModels(this.accessToken, this.projectId);this.servedModels = served.servedIds;- this.defaultServedModel = served.defaultId;- // Resolve the requested id to a served id against the live set (mirrors the- // credential provider, which builds the primary envelope).- this.servedModelName = resolveAntigravityModelId(- this.modelName,- this.servedModels,- this.defaultServedModel,- lookupFamilyDefaultVariant(this.modelName, "antigravity")- );+ // Resolve the requested id to a served id against the live set, with the+ // function the credential provider (which builds the primary envelope) and+ // the routing availability check also use.+ this.servedModelName = resolveAntigravityServedModel(this.modelName, served);log(`[Antigravity] Auth refreshed, project: ${this.projectId}, tier: ${this._displayName}, ` +`model: ${this.modelName} -> ${this.servedModelName}, served: ${this.servedModels.join(",") || "(none)"}`