Skip to content

[Bug]: Antigravity local language-server discovery breaks on Antigravity 2.34+ (--csrf_token left the command line; token now in the hub daemon descriptor) #140

Done

Description

@carrotciallo

Plugin version

2.5.0 (installed). The discovery code in question is unchanged on current main (checked 2026-11-24): antigravity_local_rpc_collect in providers/get-provider-usage still obtains the CSRF token only by scanning the language server's command line, with no hub-descriptor lookup.

Area

Provider usage helper

Environment

  • Dux Shell: dms v2.1.2
  • Quickshell: 0.3.2
  • Compositor: Hyprland (Wayland)
  • Distro: CachyOS
  • bash/jq/curl: bash 5.3.20 / jq 1.8.2 / curl 8.23.0
  • Antigravity desktop app: 2.17.0 (working) → 2.34.0 (broken)

Steps to reproduce

  1. Use AiOverviewControl with antigravity in providerSelection, with the Antigravity desktop app signed in and running.
  2. Update the Antigravity desktop app to 2.34.0 (the version current as of 2026-11-24) and relaunch it.
  3. Run ./providers/get-antigravity-usage, or watch the widget/dashboard.

Expected behavior

The adapter discovers the running app's language server via antigravity_local_rpc_collect, reads RetrieveUserQuotaSummary over loopback Connect-RPC (login method Antigravity app (local language server)), and returns all quota groups for the app's account, including Gemini Models (5h / Weekly).

Actual behavior

Local discovery silently finds nothing, so the adapter falls back to the cloud endpoint with the CLI OAuth session. On plugin 2.5.0 the visible symptom is that the Gemini Models pool disappears from the card (only Claude & OpenAI Models remain); the antigravity entries in usage-history.jsonl stop at the minute the app was updated. On 2.6.0+ the cloud fallback returns the Gemini pool again (thanks to the client-version fix in #133), but the local-RPC path itself is still dead, so the app account's own summary is never used.

Root cause: in Antigravity 2.34 the language server no longer carries --csrf_token on its command line (verified below), so the scan in antigravity_local_rpc_collect extracts an empty token and skips the server ([ -n "$csrf" ] || continue). The token has not disappeared — the hub now writes a daemon descriptor at ~/.gemini/antigravity/daemon/hub_<httpPort>.json containing pid, httpPort, httpsPort and csrfToken, and the server still rejects token-less calls with 401 missing CSRF token. This is distinct from #132 (ACP session discovery) and #133 (cloud User-Agent gating): it affects the local-RPC discovery added in #108.

Suggested fix: in antigravity_local_rpc_collect, read ~/.gemini/*/daemon/hub_*.json first — check the recorded pid is alive, take csrfToken, try httpsPort then httpPort with the existing GetUserStatus handshake — and keep the command-line scan as a fallback for older app builds. (The third-party antigravity-usage-monitor plugin already uses this descriptor as its primary discovery source.) One caveat: the descriptor is an undocumented internal format and may move again, which is why keeping the existing scan as fallback seems prudent. A locally tested patch implementing exactly this is attached under Local checks; with it, the adapter returns the local-server account with all four windows again.

Local checks

# Antigravity 2.34 language_server command line (sanitized): no --csrf_token
$ tr '\0' '\n' < /proc/$(pgrep -x language_server)/cmdline
/home/carrot/.local/opt/Antigravity/resources/bin/language_server
--standalone
--override_ide_name antigravity
--subclient_type hub
--override_ide_version 2.34.0
--https_server_port 0
--app_data_dir antigravity
--cloud_code_endpoint https://daily-cloudcode-pa.googleapis.com
--enable_sidecars
--host_bridge_url=http://127.0.0.1:<port>
--read_host_bridge_token_from_stdin
# (2.17.0 passed: --csrf_token <value> --https_server_port 0)

# Hub daemon descriptor schema (types only, no values)
$ jq 'with_entries(.value = (.value | type))' ~/.gemini/antigravity/daemon/hub_*.json
{
  "pid": "number",
  "httpPort": "number",
  "httpsPort": "number",
  "lsVersion": "string",
  "csrfToken": "string"
}

# The HTTPS port from the descriptor still requires the token
$ curl -k -X POST https://127.0.0.1:<httpsPort>/exa.language_server_pb.LanguageServerService/GetUserStatus -d '{}'
{"code":"unauthenticated","message":"unauthenticated: missing CSRF token"} (HTTP 401)
# …and answers 200 with the descriptor's csrfToken as x-codeium-csrf-token.

# Before the local patch (plugin 2.5.0, Antigravity 2.34.0)
$ ./providers/get-antigravity-usage
loginMethod: CLI OAuth (refreshed)
 - Claude & OpenAI Models (5h) 0%
 - Claude & OpenAI Models (Weekly) 0%
# (Gemini Models windows missing)

# After the local patch
loginMethod: Antigravity app (local language server)
 - Gemini Models (5h) 1.01%
 - Gemini Models (Weekly) 24.85%
 - Claude & OpenAI Models (5h) 0%
 - Claude & OpenAI Models (Weekly) 0%

Local patch against 2.5.0 `providers/get-provider-usage` (for reference):

@@ -559,6 +559,38 @@
 
   local proc_root="${ANTIGRAVITY_PROC_DIR:-/proc}" pid exe csrf port address host email n=0
   local -a ports
+  # Antigravity 2.34+ no longer puts --csrf_token on the language server's
+  # command line; the hub writes a daemon descriptor holding the ports and
+  # the token instead (~/.gemini/<product>/daemon/hub_<httpPort>.json).
+  # Try those descriptors first; the command-line scan below stays as the
+  # fallback for older builds. (Local patch 2026-11-24.)
+  local hub_file hub_pid hub_csrf hub_https hub_http hub_port
+  for hub_file in "${HOME}/.gemini/"*/daemon/hub_*.json; do
+    [ -r "$hub_file" ] || continue
+    hub_pid="$(jq -r '.pid // empty' "$hub_file" 2>/dev/null || true)"
+    [[ "$hub_pid" =~ ^[0-9]+$ ]] || continue
+    kill -0 "$hub_pid" 2>/dev/null || continue
+    hub_csrf="$(jq -r '.csrfToken // .csrf_token // empty' "$hub_file" 2>/dev/null || true)"
+    [ -n "$hub_csrf" ] || continue
+    hub_https="$(jq -r '.httpsPort // empty' "$hub_file" 2>/dev/null || true)"
+    hub_http="$(jq -r '.httpPort // empty' "$hub_file" 2>/dev/null || true)"
+    for hub_port in "$hub_https" "$hub_http"; do
+      [[ "$hub_port" =~ ^[0-9]+$ ]] || continue
+      : > "$out_dir/status.json"
+      antigravity_local_rpc_call "127.0.0.1" "$hub_port" "$hub_csrf" GetUserStatus "$out_dir/status.json" || continue
+      email="$(jq -r '.userStatus.email // empty | ascii_downcase' "$out_dir/status.json" 2>/dev/null || true)"
+      [ -n "$email" ] || continue
+      : > "$out_dir/summary.json"
+      antigravity_local_rpc_call "127.0.0.1" "$hub_port" "$hub_csrf" RetrieveUserQuotaSummary "$out_dir/summary.json" || continue
+      jq -c '(.response // .) | select((.groups | type) == "array")' "$out_dir/summary.json" > "$out_dir/$n.json" 2>/dev/null || true
+      if [ -s "$out_dir/$n.json" ]; then
+        printf '%s' "$email" > "$out_dir/$n.email"
+        n=$((n + 1))
+        break
+      fi
+      rm -f "$out_dir/$n.json"
+    done
+  done
   # Match the process by its executable, not its command line: `pgrep -f`
   # would also match any process that merely mentions the path in its
   # arguments, such as a shell or an editor.

Activity

  1. added
    bug
    on Nov 24, 2026
  2. bernardopg commented on Nov 24, 2026

    @bernardopg
    Owner

    Thank you so much for the report, @carrotciallo, and for another great investigation after #130! You showed the 2.34 command line without --csrf_token, documented the hub descriptor schema with types only (no values, which I really appreciate), confirmed the 401 missing CSRF token on the HTTPS port, and even attached a tested patch. You had already found the root cause; that made the fix straightforward.

    What was happening

    Since Antigravity 2.34, the language server runs as a hub daemon and no longer receives --csrf_token on its command line. The token now lives in ~/.gemini/antigravity/daemon/hub_<httpPort>.json (pid, httpPort, httpsPort, lsVersion, csrfToken). antigravity_local_rpc_collect only scanned the command line, so it found an empty token, skipped the server, and every account silently fell back to the cloud endpoint. The app's own RetrieveUserQuotaSummary was never used.

    Fix

    PR #141 implements the approach you suggested, with a few extra safeguards:

    • The adapter reads the hub_*.json descriptors first. It uses a descriptor only when it is a regular file owned by the user and its pid is still running, so descriptors left behind by crashed daemons are ignored.
    • The token is sent only to loopback ports that the descriptor's own process listens on, with httpsPort tried first. A descriptor naming a port another process owns never receives the token.
    • The command-line scan stays as the fallback for older builds, as you recommended, since the descriptor is an undocumented internal format.
    • The agy CLI hub writes its own descriptor too; when it and the app are signed in to the same account, that account is summarized once.
    • ANTIGRAVITY_DAEMON_DIR can point the lookup elsewhere for diagnostics; ANTIGRAVITY_NO_LOCAL_RPC=1 still turns the local path off.
    • The token still travels only through a curl --config pipe, never on argv or in the output.

    Regression coverage in tests/test-cov-b-antigravity.sh covers a token-less command line with a live descriptor, a stale descriptor, the preferred port order, a foreign port, a daemon without listeners, the shared agy/app account, and no token leaking into argv or output. Those cases fail on 2.6.0 and pass now.

    Validation

    • Live against Antigravity 2.35.0 with two signed-in accounts and a stale 2.29.0 descriptor: the app's account now reports Antigravity app (local language server) (2.6.0 reported IDE session OAuth (refreshed)), the other account keeps its cloud numbers, and there are no account errors.
    • All required checks, main CI and statement coverage passed.

    The fix is released in v2.6.1 (no restart needed, just Settings → Plugins → Check for updates). Your report is credited in the changelog and the 2.6.1 release notes.

    When you have a moment, could you update and confirm on your 2.34.0 setup that ./providers/get-antigravity-usage shows Antigravity app (local language server) with all four windows (Gemini Models and Claude & OpenAI Models, 5h and Weekly) again? If anything is still missing or looks off, please reply here with the output (no tokens, please) and I'll keep digging. I'm around for any question or feedback, too.

    Thanks again for the contribution! <3

  3. carrotciallo commented on Nov 25, 2026

    @carrotciallo
    Author

    Confirmed on my setup — thank you for the fast fix!

    Updated to v2.6.1 (from 2.5.0), Antigravity desktop still on 2.34.0. ./providers/get-antigravity-usage now reports Antigravity app (local language server) with all four windows: Gemini Models 5h 0%, Gemini Models Weekly 25.69%, Claude & OpenAI Models 5h 0%, Claude & OpenAI Models Weekly 0%, and no account errors. The widget shows the Gemini weekly window again and usage-history.jsonl is recording antigravity entries on every poll.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions