Skip to content

Contribution proposal: Antigravity agent source #1488

Description

@sambitcreate

What do you want to change?

Add Google Antigravity (Google's agentic IDE, and its CLI) as a supported agent source, exposed as ccusage antigravity daily|monthly|session and included in the unified all-agents report.

Why?

I split my work across several agents and Antigravity is the one ccusage can't see. It turns out Antigravity stores every conversation locally as SQLite databases under ~/.gemini/antigravity{,-cli,-ide,-backup}/conversations/, and each generation's token usage (input, output, cache-read, thinking, model, timestamp) is fully recoverable from those files offline — no API, no live process, no credentials. So the gap is fillable with the same read-local-logs approach as the other adapters.

How?

Each conversation DB has a gen_metadata table where every row is a GeneratorMetadata protobuf. A small hand-rolled wire-format reader decodes per-generation token counts, with a timestamp fallback chain and dedup by responseId across databases. Antigravity's opaque model ids (MODEL_PLACEHOLDER_*, gemini-3-flash-a/b/c, tier suffixes) resolve through an alias table to LiteLLM-priced names, and Gemini entries from models.dev get embedded in the pricing snapshot so offline cost calculation works for models LiteLLM hasn't published yet (e.g. gemini-3.6-flash).


Full disclosure: I got ahead of myself and opened PR #1487 before reading CONTRIBUTING.md — sorry about that. Feel free to leave it closed until this proposal is approved. The implementation there is complete and tested (469 cargo tests pass, clippy/fmt clean, verified against a real Antigravity install: 23 days of usage aggregated with correct models, tokens, and costs), and I'm happy to rework any part of it based on your feedback.

Activity

  1. pullfrog commented on Jul 24, 2026

    @pullfrog
    Contributor
  2. github-actions commented on Jul 24, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  3. byte commented on Aug 1, 2026

    @byte

    i would find this useful

  4. ryoppippi commented on Aug 3, 2026

    @ryoppippi
    Member

    Status: a partial implementation landed, and it is not the whole job

    #1544 is merged, so ccusage antigravity daily|monthly|session exists on main
    now. It landed while this proposal was still open, which was the wrong order —
    apologies, @sambitcreate. Your proposal and #1487 came first and cover more
    ground than what shipped.

    To be direct: what is on main is half-finished. It is not released yet
    (latest is v20.0.19; the antigravity commit is queued in the tagpr PR #1507), so
    we still have a free hand. Reverting 50614f13 is on the table and I would
    not argue against it if we want #1487 to be the basis instead.

    What shipped

    Reads ~/.gemini/antigravity-cli/conversations/**/*.db, decoding
    steps.metadata (CortexStepMetadata) and gen_metadata.data
    (ChatModelMetadata) by protobuf field number, recovered from the
    FileDescriptorProto blobs embedded in the agy binary. Dedupes every
    invocation on response_id, then provider_assigned_message_id, then
    message_id.

    Verified against a real install: 44,463 input / 456 output / 16,275 cache-read
    tokens and $0.0724, matching a hand calculation from the raw protobuf.

    Where it falls short of this proposal

    1. Only one data directory. It looks at antigravity-cli and misses
      antigravity, antigravity-ide and antigravity-backup. The machine it was
      developed on has only the CLI installed, which is exactly how that got missed.
      IDE users get nothing today.
    2. No model alias table. Opaque ids become antigravity-model-<id> and
      cannot be priced, so cost is silently understated. The alias table described
      in this proposal is the fix.
    3. No Gemini rates in the offline snapshot. --offline reports no cost for
      Gemini models, because is_embedded_model in ccusage-core/build.rs covers
      only Anthropic and OpenAI. Embedding models.dev Gemini entries, as proposed
      here, is the fix.
    4. Thin verification. It was validated against three chat turns in one CLI
      conversation, against 23 days across a real install in feat(adapter): add antigravity agent source #1487.
    5. Three code paths shipped unexercised. Retries actually occurring,
      subagents, and model comparison (battle mode). The dedupe is designed to be
      correct either way, but nothing has run through them.

    Items 1-3 are already solved in #1487. That is the main reason I think it should
    supersede or absorb what landed.

    What we still need

    Questions for the Antigravity team

    These are the ones no amount of local reverse engineering can settle, and getting
    them answered would let this adapter stop hedging:

    • Model id mapping. ModelUsageStats.model is a number (we see 1071 and
      1050), and the shipped descriptor names them only as
      MODEL_PLACEHOLDER_M71 / MODEL_PLACEHOLDER_M50. Is there an authoritative,
      reasonably stable id-to-name mapping we can read or vendor? Which ids are
      internal utility models rather than user-selected ones?
    • Whether input_tokens excludes cache_read_tokens. We concluded they are
      disjoint from a record carrying input_tokens 4050 against cache_read_tokens
      16275, which rules out the total-inclusive reading. Confirmation would be
      welcome, along with when cache_write_tokens is populated — we have never seen
      it set.
    • retry_infos semantics. Does it include the attempt that succeeded, or
      only the failed ones? Do failed attempts consume quota? Our dedupe is safe
      either way, but a test fixture depends on knowing which it is.
    • Subagents and battle mode. Do sub-conversations always get their own
      database, and can the same invocation appear in both a parent and a child? For
      a model comparison, are both arms charged, and is the losing arm's data
      retained?
    • model_cost, credit_cost, consumed_credits. These exist in
      ChatModelMetadata and CortexStepMetadata but are unset on the consumer
      accounts we have looked at. Which account types populate them? If any do, that
      is authoritative cost and should take priority over our LiteLLM estimate.
    • Retention. Does Antigravity prune steps or gen_metadata over time? If
      it does, a day's total shrinks on re-run, and we would rather warn about that
      than have users discover it.
    • Missing token categories. ModelUsageStats has no equivalent of Vertex's
      tool_use_prompt_token_count, or of image and audio counts. Are those folded
      into input_tokens, or dropped during normalization?
    • Schema stability, or a supported export. We decode by field number on the
      assumption that Antigravity cannot renumber fields without breaking its own
      persistence. A published .proto, or any documented local export with
      timestamps, model, and token counts, would remove that assumption entirely.

    What would help from anyone reading this

    Fixtures we do not have. Specifically: a conversation from an IDE install
    (not the CLI), one that actually retried, one that invoked a subagent,
    and one battle-mode comparison. Redacted or synthetic is fine — we only need
    the steps and gen_metadata blobs, not prompt text.

    Proposed next step

    @sambitcreate — would you be willing to reopen #1487? The sensible outcome is
    that its data-directory coverage, alias table, and pricing embedding land, either
    on top of what is now on main or by reverting 50614f13 first and taking your
    branch as the base. Your call which is less work; I am happy to do the rebasing
    either way.

    Whichever route we take, I would rather not ship v20.0.20 with the current
    half-finished version as-is.

  5. ryoppippi commented on Aug 3, 2026

    @ryoppippi
    Member

    Opened #1569 to revert #1544 for now, so v20.0.20 does not go out with the
    half-finished version.

    To be clear about intent: this is a temporary revert, not a decision to drop
    Antigravity support.
    The plan is still to ship it — just from the better base.
    Nothing about the reverse engineering is lost; the field numbers, the disjoint
    input_tokens / cache_read_tokens evidence, and the response_id dedupe
    reasoning all stay documented in the comment above.

    @sambitcreate — with main clean again, reopening #1487 becomes the
    straightforward path: it lands on an unmodified base with no need to reconcile
    against my version. Happy to do the rebase and review legwork if that helps.

    The questions for the Antigravity team in my previous comment still stand
    regardless of which implementation lands, particularly the model id mapping and
    whether model_cost / credit_cost are ever populated. Those two decide whether
    cost reporting can stop being an estimate.

  6. asdf8675309 commented on Aug 20, 2026

    @asdf8675309

    Hi @ryoppippi @sambitcreate,

    I opened a PR before reading this, fortunately the auto close thing sent me digging deeper. The ccusage adapter came after a python experiment to answer the question about my own usage from the last day.

    Details on Antigravity telemetry from the wire format on macOS:

    1. **Model names vs. IDs**: In `gen_metadata.data` (`ChatModelMetadata` / `GeneratorMetadata`), **Field 19** contains the actual  
    

    model name string (e.g., gemini-3.7-flash) whenever present, which avoids having to guess numerical placeholder IDs.
    2. input_tokens vs. cache_read_tokens: They are disjoint. Total prompt tokens = input_tokens + cache_read_tokens.
    3. Data directories:
    - CLI: ~/.gemini/antigravity-cli/conversations/*.db
    - IDE: ~/.gemini/antigravity/conversations/*.db and ~/.gemini/antigravity-ide/conversations/*.db
    - Config: ~/.config/antigravity/conversations/*.db
    - Useful environment overrides: ANTIGRAVITY_HOME, ANTIGRAVITY_DATA_DIR, AGY_HOME
    4. Subagents: Subagent runs generate their own child conversation UUIDs and are stored in separate conversation database files.
    5. Retention: Local SQLite databases are persistent per conversation and are not pruned automatically.

    In case it helps - here is an adapter branch with a zero-copy Protobuf wire decoder, SQLite loader, and test suite: https://github.com/asdf8675309/ccusage/tree/feat/antigravity-adapter

    I ran it on my machine against the python script (gist) for comparison and they matched.

  7. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    Pullfrog triage: priority:high

    A maintainer explicitly requested an implementation attempt. Detailed, repository-scoped proposal with local offline data, tests, and an existing implementation PR. Maintainer discussion confirms the feature is worthwhile and the prior revert was temporary, so it should remain open.

    Decision: kept open; Pullfrog will attempt a focused implementation PR.

  8. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.

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

    enhancementNew feature or requestpriority:highHigh user impact or an important regression.triage:resolvedResolved by a later change or current implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions