Skip to main content
Glama
Cache Hit Monitor for Antigravity

Cache Hit Monitor for Antigravity

by BotChixiaoye

Cache Hit Monitor for Antigravity

English | 简体中文

A simple, focused little tool for Google Antigravity — it does one thing in the right side pane: shows your real Prompt Cache hit rate, context window usage, and compaction (CHECKPOINT) status.

  • Zero data leakage / 100% local: Makes zero network requests, collects no telemetry, requires no API keys, and never uploads or injects your conversation data anywhere.

  • Lightweight, restrained, easy to audit: Just 1 runtime dependency (@modelcontextprotocol/sdk) and a few hundred lines of readable code you can review in minutes.

  • macOS-friendly: Built and tested natively on macOS out of the box (also works on Linux; on Windows, ensure python3 is available in PATH).

  • A practical plugin starter example: Cleanly demonstrates how to combine an Antigravity aux_pane MCP App, an app-only polling tool, and a silent PostInvocation hook.

Note: The side-pane UI labels are currently in Simplified Chinese.

Key Features & Principles

  • Zero Context Intrusion & Zero Cache Busting: Runs in Antigravity's right side pane (aux_pane -> Cache Monitor). Data polling uses an app-only MCP tool invisible to the model, and the background PostInvocation hook only records the active transcript path locally and always returns {}.

  • 100% Ground-Truth Metrics: Reads server-reported fields directly from local transcript_full.jsonl (input_tokens, cache_read_tokens, output_tokens, model, created_at, tool_calls, CHECKPOINT). No character-based token estimation, no rough composition attribution, and no synthetic counters.

  • Honest Context Limits: Displays context bar & percentage only for verified Gemini model limits (gemini-4-neon*: 512k; gemini-4-carbon/argon/hydrogen, gemini-3*, gemini-2.5*: 1M), warning at 75%. For all other models, displays the exact absolute token count only.

  • Compaction-Aware: Recognizes both standalone /compact turns and mid-turn automatic CHECKPOINT compactions—preserving the compaction call's real cache hit rate and displaying the exact before → after context drop once the next model response arrives (never estimated beforehand).

  • Compact Grouped Timeline: Shows the latest 10 turns auto-following the active conversation; click any turn to expand step-by-step tool actions, cache hit rates, token ratios, and timestamps.

Related MCP server: codex-goal-viewer

Requirements

  • Google Antigravity (desktop app / IDE with MCP App side-pane support)

  • Node.js 18+

  • Python 3 (used by the silent PostInvocation hook)

Installation

  1. Clone this repository into Antigravity's global plugins directory:

git clone <your-repo-url> ~/.gemini/config/plugins/cache-hit-monitor
cd ~/.gemini/config/plugins/cache-hit-monitor
  1. Install the runtime dependency (@modelcontextprotocol/sdk):

npm install --omit=dev

(A prebuilt ui/app.html bundle is included. If you modify ui-src/, install dev dependencies and rebuild with npm install && npm run build:ui.)

  1. Enable/reload plugins in Antigravity (or restart Antigravity).

  2. Open the right side pane (+ -> Cache Monitor). It polls local logs every 2.5s and automatically follows your active conversation.

Configuration

Edit config.json to adjust model limits or alert thresholds:

{
  "geminiContextWindows": [
    { "prefix": "gemini-4-neon", "limit": 512000 },
    { "prefix": "gemini-4-carbon", "limit": 1000000 },
    { "prefix": "gemini-4-argon", "limit": 1000000 },
    { "prefix": "gemini-4-hydrogen", "limit": 1000000 },
    { "prefix": "gemini-3", "limit": 1000000 },
    { "prefix": "gemini-2.5", "limit": 1000000 }
  ],
  "cacheDropThreshold": 0.5,
  "cacheExpiryGapSeconds": 300,
  "contextWarnRatio": 0.75
}

Field

Description

Default

geminiContextWindows

Prefix-matched context window limits (tokens) for Gemini models

See above

cacheDropThreshold

Turn hit rate below which drop-fact badges are highlighted

0.5

cacheExpiryGapSeconds

Idle gap (seconds) surfaced as an objective fact on cache drop

300

contextWarnRatio

Context window ratio that triggers the high-waterline /compact hint

0.75

How It Works

Antigravity ──(PostInvocation hook)──▶ scripts/track_active.py ──▶ ${PLUGIN_DATA}/active.json
                                                                           │
Antigravity Side Pane (ui/app.html) ◀──(app-only MCP poll)──▶ server/index.mjs ──▶ transcript_full.jsonl
  • Local-only: No network calls, no telemetry, no external API keys.

  • Compatibility note: This plugin parses Antigravity's local transcript_full.jsonl schema (USER_INPUT, PLANNER_RESPONSE, CHECKPOINT). If a future Antigravity release changes local transcript fields, server/index.mjs may need an update.

Development

npm install
npm run build:ui

After changing server/index.mjs or rebuilding ui/app.html, reload the MCP server / reopen the Cache Monitor pane in Antigravity.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides a local MCP interface to query captured, PII-scrubbed prompt telemetry from coding agents and browser chats, enabling time summaries, prompt search, and activity analysis without data leaving the machine.
      9
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables users to view average token throughput, output and reasoning token counts, and recent speed trends for local Codex Desktop conversations through a session panel without modifying the client.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables reading locally recorded Codex execution traces — reconstructed requests, nested tool calls and their results, compaction history, and generation timing — browsed alongside the current conversation through timeline, ledger, and inspector views. Also lets users register additional trace directories and inspect large recordings incrementally without any upload or remote service.
      2
      MIT