Skip to content

Fix Antigravity agy cold-start quota readiness wait - #2665

Merged
steipete merged 1 commit into
steipete:mainfrom
Yuxin-Qiao:codex/fix-antigravity-agi-cold-start
Aug 6, 2026
Merged

Fix Antigravity agy cold-start quota readiness wait#2665
steipete merged 1 commit into
steipete:mainfrom
Yuxin-Qiao:codex/fix-antigravity-agi-cold-start

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wait up to 15s (was 5s) for a freshly spawned agy CLI HTTPS session to become quota-ready. Live tests showed a new agy needs ~3s for macOS keyring auth, then more time before quota endpoints answer; the 5s window reliably missed it.
  • While waiting, keep polling when a parseable snapshot has no matching account email yet: fresh agy processes can answer quota endpoints before the signed-in userInfo email is available, and the selected-account guard would otherwise reject the cold-start snapshot.
  • Add a focused test: cli HTTPS keeps waiting while snapshot account is not ready yet.

Reproduction environment

  • macOS arm64, Swift 6.3.3 toolchain
  • agy 1.1.10 installed via brew install --cask antigravity-cli (/opt/homebrew/bin/agy)
  • Antigravity.app closed for the whole run (no language_server process)
  • Base: 7ace3d0b1; all reproduction commands were one-shot CLI fetches: swift run CodexBarCLI usage --provider antigravity --verbose

Before: cold start fails inside the 5s window

Fresh agy spawn at T+0s. Every probe in the window returns transient init errors:

T+1s  HTTP 500 {"code":"internal","message":"internal: failed to get load code assist
      response: error getting token source: You are not logged into Antigravity."}
T+2s  same error repeated; second listening port only TLS errors
T+5s  CLI gives up: "Antigravity CLI session stopping (one-shot CLI fetch)"

agy's own log shows keyring auth completes only at ~T+3.6s:

I0805 12:09:06.981  auth.go:137] ChainedAuth: authenticated via keyring (effective: keyring)
I0805 12:09:06.981  server_oauth.go:194] OAuth: authenticated successfully as <redacted>

Result: strategy chain falls through to OAuth, which returns only an all-100% availability row with no reset times (the known "availability-style fallback" payload).

After: cold start succeeds with full quota

2026-08-05T12:17:04+0800 ... Antigravity CLI session started (binary=agy)
2026-08-05T12:17:07+0800 ... == Antigravity (cli) ==
Gemini Models: 2% left [------------]   Resets tomorrow, 11:52 AM
Claude and GPT: 100% left [============] Resets 5:17 PM
Account: <redacted>
Plan: <redacted>

Data returned ~3s after spawn, before the 15s deadline, straight from the agy CLI HTTPS source (no OAuth fallback).

Parity check: cli source == app source

Same machine, same account; JSON payloads from --format json compared programmatically:

Field app source cli source Match
Gemini weekly usedPercent 97.8170183 97.8170183 identical
Gemini weekly resetsAt 2026-08-06T03:52:58Z 2026-08-06T03:52:58Z identical
Claude+GPT weekly usedPercent 0 0 identical
account identity (email, plan) same identical
5h + Claude/GPT weekly resetsAt T T + run gap fetch-time-relative only

Only fetch-time-relative reset timestamps shift by the seconds between the two runs; all fixed-schedule values and all usage fractions are byte-identical.

Test

  • swift test --filter 'AntigravityCLIHTTPSFetchStrategyTests|AntigravityWarmAgyReuseTests|AntigravityCLISessionTests' - 98 tests passed
  • make check - 0 violations, 0 serious

CI

All checks green on this PR: swift-test-macos (2 shards), build-linux-cli (arm64/x64/musl), lint, lint-build-test, changes, GitGuardian Security Checks.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d0703e0b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +545 to +547
if AntigravitySelectedAccountGuard.matches(
snapshotAccountEmail: readySnapshot.accountEmail,
expectedAccountEmail: expectedAccountEmail)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't keep polling after a known account mismatch

When auto mode has a selected Antigravity account and the spawned agy session is already returning a different non-empty email, this matches failure is not a readiness condition that polling can fix. The loop now waits until the full 15s deadline before throwing accountMismatch and letting the pipeline fall through to OAuth, whereas before the ready snapshot was returned and the selected-account validation triggered fallback immediately. This makes every refresh stall for users whose local agy is signed into a different account than the selected OAuth account; only the missing-email case should keep waiting.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 5, 2026, 9:56 PM ET / August 6, 2026, 01:56 UTC.

ClawSweeper review

What this changes

The PR extends Antigravity’s freshly started agy CLI quota wait from 5 to 15 seconds and retries incomplete account-identity snapshots.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this PR open for a narrow repair: its cold-start retry is useful, but a ready snapshot with a different non-empty account email now waits up to 15 seconds before the established OAuth fallback can run.

Priority: P2
Reviewed head: 1d0703e0b90c7c739384383d27c67516869629a8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The real-world proof is strong, but the unchanged selected-account mismatch branch needs a small correctness repair before merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies a redacted before/after macOS CLI run, agy authentication timing, and after-fix quota output.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies a redacted before/after macOS CLI run, agy authentication timing, and after-fix quota output.
Evidence reviewed 4 items Current main behavior: Current main waits five seconds and returns the first parseable CLI snapshot; the PR changes that readiness path but is not already implemented on main.
Known mismatch is retried: At the PR head, every non-matching ready snapshot records accountMismatch and continues polling, including a non-empty different account email.
Existing fallback contract: The selected-account guard explicitly rejects a different ambient account in auto mode so the pipeline can fall through to OAuth.
Findings 1 actionable finding [P2] Return known account mismatches without waiting
Security None None.

How this fits together

CodexBar’s Antigravity provider probes local app and agy CLI quota sources before OAuth fallback. The CLI path starts or reuses agy, waits for a parseable quota snapshot, then supplies usage and account identity to the provider pipeline.

flowchart LR
A[Usage refresh] --> B[Antigravity provider]
B --> C[Start agy CLI session]
C --> D[Poll quota snapshot]
D --> E{Account identity state}
E -->|matching or unselected| F[Return CLI quota data]
E -->|missing identity| D
E -->|different identity| G[OAuth fallback]
F --> H[Usage display]
G --> H
Loading

Before merge

  • Return known account mismatches without waiting (P2) - A ready snapshot with a different non-empty email cannot become the selected account through polling. This waits until the 15-second deadline before accountMismatch reaches the established fallback path, slowing every refresh for users whose agy account differs. Retry only a missing email and add the distinct mismatch regression case.
  • Resolve merge risk (P2) - Selected-account users whose local agy session is already signed into a different account can wait the full 15-second readiness window before OAuth fallback runs.
  • Complete next step (P2) - A narrow code-and-test repair can resolve the confirmed selected-account delay.

Findings

  • [P2] Return known account mismatches without waiting — Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift:543-563
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 2 files, +74/-4 lines The PR changes provider readiness behavior and adds one focused test.

Merge-risk options

Maintainer options:

  1. Separate missing identity from an account mismatch (recommended)
    Retry only empty account-email snapshots and return a non-empty mismatch immediately to preserve fast OAuth fallback.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve immediate selected-account fallback for non-empty differing emails; add a focused mismatch regression test alongside the missing-email retry test.

Technical review

Best possible solution:

Keep the longer cold-start window, but retry only snapshots with no account email and immediately return a ready snapshot with a different non-empty email to the existing fallback guard.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: select one Antigravity account while agy returns a different non-empty email; the new loop treats it as unready and continues until its deadline.

Is this the best way to solve the issue?

No: the missing-email retry is appropriate for cold start, but a non-empty different email is a known account mismatch and should preserve the existing immediate fallback behavior.

Full review comments:

  • [P2] Return known account mismatches without waiting — Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift:543-563
    A ready snapshot with a different non-empty email cannot become the selected account through polling. This waits until the 15-second deadline before accountMismatch reaches the established fallback path, slowing every refresh for users whose agy account differs. Retry only a missing email and add the distinct mismatch regression case.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4cdb349cbc57.

Labels

Label justifications:

  • P2: The defect can make a provider refresh noticeably slower for selected-account users, with limited scope.
  • merge-risk: 🚨 auth-provider: The changed readiness decision uses the selected account’s email to accept or reject local CLI data.
  • merge-risk: 🚨 availability: A known account mismatch can delay fallback until the extended timeout expires.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body supplies a redacted before/after macOS CLI run, agy authentication timing, and after-fix quota output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies a redacted before/after macOS CLI run, agy authentication timing, and after-fix quota output.

Evidence

Acceptance criteria:

  • [P1] swift test --filter AntigravityCLIHTTPSFetchStrategyTests.
  • [P1] make check.

What I checked:

Likely related people:

  • Peter Steinberger: Recent provider-descriptor refactors and several Antigravity warm-session fixes are in this file’s history. (role: recent area contributor; confidence: high; commits: fb66e63e8719, 9c5628c08dc2, 5e7c3b98b4b0; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift)
  • Kim Junmo: History attributes the warm agy reuse path that this change extends to Kim Junmo. (role: introduced warm-session behavior; confidence: medium; commits: 62c3f8c0cb05, c47e50f98d27; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift)
  • Yuxin Qiao: The file history includes prior merged Antigravity quota UI work in addition to this proposed change. (role: prior Antigravity contributor; confidence: medium; commits: 70f37afcb522; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Return immediately on a non-empty selected-account mismatch.
  • Add a focused regression test for the non-empty mismatch path.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-05T05:10:25.594Z sha 1d0703e :: needs changes before merge. :: [P2] Return known account mismatches without waiting
  • reviewed 2026-08-05T06:44:25.374Z sha 1d0703e :: needs changes before merge. :: [P2] Return known account mismatches without waiting
  • reviewed 2026-08-05T13:31:23.870Z sha 1d0703e :: needs changes before merge. :: [P2] Return known account mismatches without waiting

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. label Aug 5, 2026
@steipete
steipete merged commit 1118a62 into steipete:main Aug 6, 2026
9 checks passed
steipete added a commit to Yuxin-Qiao/CodexBar that referenced this pull request Aug 6, 2026
@steipete

steipete commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Landed. Verified before merge: the cold-start race is real (agy keyring auth ~3.6s vs the old 5s deadline → reliable fall-through to the degraded OAuth path from #2427); the new wait is strictly bounded (15s, spawn path only, poll sleep capped to remaining), warm-path latency untouched, and at deadline the retained error still routes to the next strategy. Known tradeoff: a genuine account mismatch on cold spawn now burns the full window before failing — acceptable since mid-init nil email is indistinguishable. Local: 98/98 across the CLI strategy/warm-reuse/session suites incl. the new not-ready polling test. CI green at merge. Thanks @Yuxin-Qiao!

steipete added a commit that referenced this pull request Aug 6, 2026
* Document Antigravity sources when the app is closed

* docs: keep Antigravity experimental tag and reflect cold-start readiness wait (#2665)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants