Skip to content

[Bug]: Antigravity rememberModel() poisons modelId to null on effort-suffix variation, disabling MODEL_IDS fallback and leaving models unpriced #43081

Done

Description

@grandprixgp

Before submitting

  • I searched existing issues and did not find a duplicate (checked #40349 which fixed -orchestrator and 1537 on main, and #31298 which covers missing .db files; this issue covers the distinct rememberModel() poisoning, MODEL_IDS suppression, mismatched idx join, and remaining unmapped variants still present on main).
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Have multiple Antigravity conversation .db files under ~/.gemini/antigravity-cli/conversations/ where a numeric modelId (e.g. 1532 for gemini-4-neon, 1417 for gemini-4-argon, 1318 for gemini-3.8-flash) appears with its bare model name in protobuf field 19 (gemini-4-neon) on most rows, and falls back to its display name in field 21 (Gemini 4 Neon (High) -> normalized to gemini-4-neon-high) on at least one row.
  2. Have any step record whose usage entry lacks a matching gen_metadata row (or has step.idx >= generations.length).
  3. Open Usage -> Cost (24h or 30d).

Expected behavior

  • Effort-suffix variations of the same base model (gemini-4-neon vs gemini-4-neon-high) do not poison the learned modelId -> modelName mapping to null.
  • Step records resolve to their concrete model name and are priced using LiteLLM rates.
  • Remaining Antigravity routing/variant slugs (gemini-3.8-flash-n, gemini-pro-orchestrator / Orchestrator (Carbon), gemini-4-argon-r, gemini-4-argon-trial) map to their base model rates.

Actual behavior

Four compounding bugs in apps/server/src/provider/Drivers/antigravityUsageReader.ts (all verified still present on current main) cause Antigravity records — heavily impacting subagent/orchestrator workloads — to be charted as Unpriced ($0.00):

  1. rememberModel() poisons modelId -> null on effort-suffix variation (antigravityUsageReader.ts:179-182 on main):

    function rememberModel(models: Map<number, string | null>, id: number, model: string | null) {
      const previous = models.get(id);
      models.set(id, previous === undefined || previous === model ? model : null);
    }

    In Antigravity's protobufs, field 19 carries the bare model name (gemini-4-neon) and field 21 carries the display name with effort (Gemini 4 Neon (High) -> gemini-4-neon-high). Whenever even a single row across all scanned DBs omits field 19 and falls back to field 21, rememberModel sees two different strings for the same modelId and permanently poisons models.get(id) to null.

    • Across 369 real DBs, 9 of 17 model IDs were poisoned to null: 1318, 1320, 1417, 1418, 1427, 1437, 1526, 1532, 1533.
    • Example: modelId = 1532 had gemini-4-neon on 9,542 rows and gemini-4-neon-high on just 4 rows — those 4 rows poisoned models.get(1532) = null.
  2. learned === null also suppresses the static MODEL_IDS fallback (antigravityUsageReader.ts:568-575 on main):

    const learned = models.get(candidate.modelId);
    const fallback = learned === null ? undefined : MODEL_IDS[candidate.modelId];

    Because learned === null clears fallback, even IDs explicitly listed in MODEL_IDS (1318, 1320, 1417, 1418) fall through to unpriced antigravity-model-<id>.

  3. usageCandidates() joins steps to gen_metadata on mismatched idx spaces (antigravityUsageReader.ts:349-364 on main):

    const generationModels = new Map(generations.map(({ idx, entry }) => [idx, entry]));
    ...
    const generation = source === "step" ? generationModels.get(idx) : undefined;

    steps.idx is the conversation step index (0..3333+, including user/tool/thinking steps), while gen_metadata.idx is the 0-based generation sequence (0..1133). Looking up generationModels.get(step.idx) matches an unrelated generation or returns undefined once step.idx >= generations.length, exposing step-only usage rows to bugs (1) and (2).

  4. Remaining unmapped Antigravity variant slugs & numeric IDs still missing on main (follow-up to #40349):

    • gemini-3.8-flash-n (modelId 1318/1320, 237.3M tokens in 30d) -> should rate as gemini-3.8-flash
    • gemini-pro-orchestrator (modelId 1667, display Orchestrator (Carbon), 82.9M tokens) -> should rate as gemini-4-carbon
    • gemini-4-argon-r (1417, 14.6M tokens) & gemini-4-argon-trial (1417/1418, 5.4M tokens) -> should rate as gemini-4-argon
    • Missing static MODEL_IDS: 1427/1437 (gemini-4-carbon), 1525/1526/1527 (gemini-4-hydrogen), 1532/1533 (gemini-4-neon), 1667 (gemini-pro-orchestrator), 1669 (gemini-4-hydrogen-orchestrator).

Impact

Major degradation or frequent failure

Version or commit

0.1.11 (59651c1761f6c63e9b6056839067066968e6a406), bugs 1-4 verified still present on current main

Environment

Ubuntu 26.04 + Windows 11, T3 Code 0.1.11, Antigravity CLI (agy)

Logs or stack traces

Observed modelId -> raw protobuf strings across 369 local Antigravity .db files:
  modelId=1318: {"gemini-3.8-flash-n": 2149, "Gemini 3.8 Flash (High)": 4079, "gemini-3.8-flash": 1928} -> learned=null
  modelId=1320: {"gemini-3.8-flash-n": 2, "Gemini 3.8 Flash (Low)": 127, "gemini-3.8-flash": 125}       -> learned=null
  modelId=1417: {"gemini-4-argon-trial": 41, "Gemini 4 Argon (High)": 164, "gemini-4-argon-r": 122}     -> learned=null
  modelId=1418: {"gemini-4-argon-trial": 49, "Gemini 4 Argon (Medium)": 50}                             -> learned=null
  modelId=1427: {"gemini-4-carbon": 1727, "Gemini 4 Carbon (High)": 1729}                               -> learned=null
  modelId=1437: {"gemini-4-carbon": 2510, "Gemini 4 Carbon (Medium)": 2511}                             -> learned=null
  modelId=1526: {"gemini-4-hydrogen": 1354, "Gemini 4 Hydrogen (Medium)": 1355}                         -> learned=null
  modelId=1532: {"gemini-4-neon": 9542, "Gemini 4 Neon (High)": 9546}                                   -> learned=null
  modelId=1533: {"gemini-4-neon": 2709, "Gemini 4 Neon (Medium)": 2711}                                 -> learned=null
  modelId=1667: {"gemini-pro-orchestrator": 459, "Orchestrator (Carbon)": 460}
  modelId=1669: {"gemini-flash-worker-agy": 6736, "Gemini 4 Hydrogen (Orchestrator)": 6736}

Resulting unpriced fallback records in 30d window:
  antigravity-model-1437: 10.52M tokens (unpriced)
  antigravity-model-1532:  9.19M tokens (unpriced; 3.12M in last 24h alone)
  antigravity-model-1427:  7.90M tokens (unpriced)
  antigravity-model-1667:  3.89M tokens (unpriced)
  antigravity-model-1537:  3.22M tokens (unpriced)
  antigravity-model-1417:  2.67M tokens (unpriced)
  antigravity-model-1533:  2.07M tokens (unpriced)
  antigravity-model-1526:  0.78M tokens (unpriced)
  antigravity-model-1318:  0.78M tokens (unpriced)

Workaround

None without manually adding custom price overrides for every antigravity-model-<id> and unmapped variant slug in Usage settings.

Suggested fix

  1. In rememberModel(), compare normalized base models via antigravityRateModel(model) (so gemini-4-neon and gemini-4-neon-high agree on gemini-4-neon instead of poisoning to null).
  2. Do not suppress MODEL_IDS[candidate.modelId] when observed variants share the same base model.
  3. Remove the cross-table generationModels.get(step.idx) lookup (rely on usage dedupe key merging + learned/static modelId instead).
  4. Extend antigravityRateModel() and MODEL_IDS for gemini-3.8-flash-n, gemini-pro-orchestrator, gemini-4-argon-r, gemini-4-argon-trial, and the newer numeric IDs above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions