Skip to content

Instantly share code, notes, and snippets.

@amirhossein-ka
Created October 2, 2026 11:46
Show Gist options
  • Select an option

  • Save amirhossein-ka/0f9e9f077c23108c3facdfa42740ff77 to your computer and use it in GitHub Desktop.

Select an option

Save amirhossein-ka/0f9e9f077c23108c3facdfa42740ff77 to your computer and use it in GitHub Desktop.
Patch Antigravity CLI eligibilty

Antigravity CLI (agy) Location Ineligibility Bug & Fix Guide

Note: This work is done with help of Google AntiGravity with Gemini 3.8

Problem Summary

When running agy in CLI environments from certain geographic regions or proxy endpoints, users with valid standard-tier accounts encounter:

Eligibility check failed: Your current account is not eligible for Antigravity, because it is not currently available in your location.

However, the same account and network connection work normally in IDE integrations (e.g., GoLand, VS Code).


Root Cause

1. Backend Response

When authenticating via Google's loadCodeAssist internal endpoint, Google returns account tier availability:

{
  "currentTier": {
    "id": "standard-tier",
    "name": "Antigravity",
    "description": "Unlimited coding assistant with the most powerful Gemini models"
  },
  "allowedTiers": [
    { "id": "standard-tier", "name": "Antigravity" }
  ],
  "ineligibleTiers": [
    {
      "tierId": "free-tier",
      "reasonCode": "UNSUPPORTED_LOCATION",
      "reasonMessage": "Your current account is not eligible for Antigravity, because it is not currently available in your location."
    }
  ]
}

2. Discrepancy Between IDE and CLI

  • IDE (agy_acp_server): Checks if current_tier and initial_project_id. Because standard-tier is active, it ignores ineligibleTiers and succeeds.
  • CLI (agy Go binary): Starting with the consumer/free-tier onboarding update (version ~1.2.13), server_oauth.go / IneligibilityFromResult inspects ineligibleTiers. Because free-tier is listed with UNSUPPORTED_LOCATION, it sets isEligible = false, blocking prompt dispatch.

Auto-Update Behavior

How to Disable Auto-Update

The CLI binary checks the environment variable AGY_CLI_DISABLE_AUTO_UPDATE. To disable background auto-updates:

  • For Bash/Zsh:
    export AGY_CLI_DISABLE_AUTO_UPDATE=1
  • For Fish shell:
    set -Ux AGY_CLI_DISABLE_AUTO_UPDATE 1

The Binary Patch

Disassembly Analysis

In the Go binary (agy), the function backend.IneligibilityFromResult computes eligibility:

# Entry point:
0x8e3c44a: push   rbp
0x8e3c44b: mov    rbp, rsp
0x8e3c44e: sub    rsp, 0x68
...
0x8e3c462: cmp    QWORD PTR [rax+0x1b8], 0x0
0x8e3c46a: je     0x8e3c5cb    # Branch to eligible exit

# Eligible exit block (at 0x8e3c5cb):
0x8e3c5cb: lea    rax, [rip+0x213525e]
0x8e3c5d2: call   0x66f9340
0x8e3c5d7: mov    BYTE PTR [rax+0x8], 0x1   # isEligible = true
0x8e3c5db: mov    BYTE PTR [rax+0x20], 0x0  # hasError = false
0x8e3c5df: xor    ebx, ebx
0x8e3c5e1: xor    ecx, ecx
0x8e3c5e3: add    rsp, 0x68
0x8e3c5e7: pop    rbp
0x8e3c5e8: ret

The 14-Byte Replacement

Replacing cmp + je at 0x8e3c462 with an unconditional jump jmp 0x8e3c5cb + NOPs forces IneligibilityFromResult to return isEligible = true.

  • Original bytes (14 bytes): 48 83 b8 b8 01 00 00 00 0f 84 5b 01 00 00
  • Patched bytes (14 bytes): e9 64 01 00 00 90 90 90 90 90 90 90 90 90

Reproducible Automated Script

Script patch_agy.py searches for the signature pattern dynamically (so even if binary offsets change in future minor builds, it locates IneligibilityFromResult by matching the success block signature mov byte ptr [rax+0x8], 1), makes a backup to agy.orig, and applies the patch cleanly.

Running the script manually:

python3 patch_agy.py ~/.local/bin/agy
#!/usr/bin/env python3
"""
patch_agy.py
Automated patcher for Antigravity CLI (agy).
Bypasses the false-positive geo-ineligibility check in 'IneligibilityFromResult'
when the account has a valid standard-tier but free-tier is marked UNSUPPORTED_LOCATION.
"""
import sys
import os
import shutil
import re
DEFAULT_BIN = os.path.expanduser("~/.local/bin/agy")
def patch_binary(target_path=DEFAULT_BIN):
if not os.path.exists(target_path):
print(f"[-] Target binary not found: {target_path}")
return False
print(f"[*] Reading {target_path}...")
with open(target_path, "rb") as f:
data = bytearray(f.read())
# Pattern:
# 48 83 b8 b8 01 00 00 00 -> cmp qword ptr [rax+0x1b8], 0
# 0f 84 ?? ?? 00 00 -> je <target>
pattern = re.compile(rb'\x48\x83\xb8\xb8\x01\x00\x00\x00\x0f\x84(..)\x00\x00')
# Signature of success block (sets isEligible = true):
# c6 40 08 01 -> mov byte ptr [rax+0x8], 1
# c6 40 20 00 -> mov byte ptr [rax+0x20], 0
SUCCESS_SIG = b'\xc6\x40\x08\x01\xc6\x40\x20\x00'
candidates = []
for m in pattern.finditer(data):
offset = m.start()
disp = int.from_bytes(m.group(1), 'little', signed=True)
target = offset + 14 + disp
if SUCCESS_SIG in data[target:target+50]:
candidates.append((offset, target))
if not candidates:
# Check if already patched:
# e9 ?? ?? ?? ?? 90 90 90 90 90 90 90 90 90
already_patched = re.compile(rb'\xe9(....)\x90{9}')
for m in already_patched.finditer(data):
offset = m.start()
disp = int.from_bytes(m.group(1), 'little', signed=True)
target = offset + 5 + disp
if SUCCESS_SIG in data[target:target+50]:
print(f"[+] Binary is ALREADY patched at {hex(offset)} -> {hex(target)}!")
return True
print("[-] Could not find IneligibilityFromResult pattern. The binary structure may have changed.")
return False
if len(candidates) > 1:
print(f"[-] Ambiguous matches found ({len(candidates)}). Aborting for safety.")
return False
offset, target = candidates[0]
print(f"[+] Found IneligibilityFromResult entry at {hex(offset)} -> target {hex(target)}")
# Backup original binary
backup_path = target_path + ".orig"
if not os.path.exists(backup_path):
print(f"[*] Backing up original binary to {backup_path}...")
shutil.copy2(target_path, backup_path)
else:
print(f"[*] Backup already exists at {backup_path}")
# Build 14-byte patch:
# jmp target: opcode 0xe9, 4-byte displacement relative to next instruction (offset + 5)
jmp_disp = target - (offset + 5)
patch = bytes([0xe9]) + jmp_disp.to_bytes(4, 'little', signed=True) + b'\x90' * 9
assert len(patch) == 14
data[offset:offset+14] = patch
# Write patched file atomically
tmp_path = target_path + ".tmp"
with open(tmp_path, "wb") as f:
f.write(data)
os.chmod(tmp_path, 0o755)
os.replace(tmp_path, target_path)
print(f"[+] Successfully patched {target_path}!")
return True
if __name__ == "__main__":
path = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_BIN
success = patch_binary(path)
sys.exit(0 if success else 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment