Skip to content

fix(server): Antigravity limits no longer show old readings after a failed probe - #34389

Open
mths-mcfs wants to merge 16 commits into
pingdotgg:mainfrom
mths-mcfs:fix/antigravity-cli-usage-limits
Open

mths-mcfs wants to merge 16 commits into
pingdotgg:mainfrom
mths-mcfs:fix/antigravity-cli-usage-limits

Conversation

@mths-mcfs

@mths-mcfs mths-mcfs commented Nov 11, 2026 •

Copy link
Copy Markdown

Problem

After Antigravity limits load once, a later failed read keeps the old figures on Usage > Limits with no notice, so they look current. #34381 shows it: when the probe's refresh is rejected, the panel "keeps the earlier figures, which never update". The maintainer's note there: "A failed probe should not keep silently showing old readings as current."

#39544 fixes which credential the probe reads. Its CodeRabbit review flags the part it leaves: when the probe cannot read the current account it returns probeFailed, and resolveUsageLimitsAfterProbe keeps showing the previous successful limits. This PR covers that part and touches none of #39544's files.

Change

Antigravity now publishes a failed read as failed: no windows, plus the probe's message. Web and mobile already show that message through the existing limit notices. The next good read brings the windows back.

 AntigravityProvider.refreshUsage
   draft.usageLimits =
+    probed is probeFailed ? probed :                                # failed read shows as failed
     resolveUsageLimitsAfterProbe(published, probed)                 # newer good read still wins, as on main
 managedProvider.applySnapshotBase
+  if retainUsageLimitsOnProbeFailure === false and probed is probeFailed
+    publish probed
   else resolveUsageLimitsAfterProbe(...)                           # unchanged for every other provider

The old reading is held back in two places, the provider's draft and the managed provider's republish, so both change. retainUsageLimitsOnProbeFailure defaults to true, so other providers keep the retention added in #9507.

Not in this PR: after sign-out or an account switch, enrichment can still republish the previous account's limits. That already happens on main. Fixing it means changing how the managed provider publishes enrichment. I tried, and each attempt opened a new ordering problem (a stale flash, a frozen reading after a cancelled refresh, a blocked OpenCode refresh). All of those were reverted here. #39672 takes that on in the managed provider.

Scope

Bug fix for the second half of #34381 (reopened by the maintainer). Complements #39544. The earlier version of this branch, which reported limits as unsupported on the agy CLI, is gone. #39544 replaces it.

Verification

  • apps/server/src/provider/AntigravityProvider.test.ts, case "publishes each limits read, showing a failed read as failed until one recovers": a good read (75%), a failed read, a recovery, an older good read that must not replace a newer one, then unsupported. Each read is gated by a Deferred. Each step checks the refresh result, what streamChanges published (it subscribes before the read completes and collects up to a barrier), and getSnapshot. None of this depends on scheduler order.
    • Suppressing only the stream publish of the failed read makes it fail.
    • With main's production code it fails: the failed read shows as the 75% reading from 12:00:00.
    • Reverting either half of the change (the draft or the managed-provider option) also fails it.
    • On this branch it passes. It ran 10 times in a row, and under a scheduler-yield preload with budgets 1, 12, 25, 40, 80, 100 and 2048.
  • packages/provider-core tests (285) and apps/server src/provider + src/usage (1273) pass.
  • vp run check:changed passes, with typecheck rerun uncached across 27 packages.
  • Not checked: the notice in a real client signed in to Google. It was confirmed by reading collectLimitNotices, not in a running app.

Known limitation, not changed here: if the provider status cache write is slow, ProviderRegistry's queue can apply an older snapshot after a newer one. A failed read can then briefly show the previous bars before the failure returns (probeFailed → 75% → probeFailed). The queue already reorders on main, where the bars just stayed at 75%. Fixing it belongs in the registry's ordering.

Known trade-off: the 5-minute background refresh does not retry. A single 5xx or timeout now replaces the bars with "Could not read limits." until the next good read.

Done with Claude Code (Claude Opus 5.5). Reviewed by Codex GPT-6.2 Sol and Claude Sonnet 5.5.

🤖 Generated with Claude Code

… with the agy CLI

The usage probe always read the profile's acp_token.json. Only the ACP
executable writes that file. With the agy CLI as the binary path, a token
left by an earlier ACP sign-in was still read, and Usage > Limits showed
that account's quota.

The probe now asks which runtime resolves and reports limits as
unavailable for the CLI without reading the profile token. If the runtime
stops resolving, the last known answer holds.

Refs pingdotgg#34381

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 11, 2026
@mths-mcfs
mths-mcfs marked this pull request as ready for review November 12, 2026 21:37
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 93e70cf and ec71e5c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The managed provider adds an option to publish failed usage probes without retaining prior limits. Antigravity disables retention and updates its tests to check published limits across multiple probe outcomes.

Changes: Usage probe limits

Layer / File(s) Summary
Managed provider failure handling
packages/provider-core/src/server/managedProvider.ts
makeManagedServerProvider adds retainUsageLimitsOnProbeFailure. When set to false, a probeFailed result uses the probed limits instead of resolving them against previously published limits.
Antigravity integration and tests
apps/server/src/provider/AntigravityProvider.ts, apps/server/src/provider/AntigravityProvider.test.ts
Antigravity sets the option to false and publishes failed probe results directly. Tests check published and current limits for successful, failed, recovered, earlier-timestamped, and unsupported results. The test helper subscribes to the snapshot stream before awaiting its first matching result.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#38809: Changes Antigravity limit retention after probe failures and covers account identity.
  • pingdotgg/t3code#39740: Changes Antigravity usage refresh on session start and tests retained limits after probe failures.
  • pingdotgg/t3code#39544: Changes the Antigravity credential probe flow, which interacts with failed-probe handling.

Suggested labels: bugfix

Suggested reviewers: t3dotgg, maseeek, juliusmarminge, macroscopeapp

Merge Risk: Minimal · previous review 93e70

Failed Antigravity limit reads are now published as failures instead of leaving stale quota windows shown as current. Other providers keep their existing behavior. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Antigravity usage limits no longer show old readings after a failed probe. It follows the conventional commit form and matches the raw summary, which describes publish…
Description check Passed The description follows the template. It has Problem, Change, Scope and Verification sections, each with specific content. It explains the bug, links #34381 and #39544, gives a diff of the change, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: Antigravity usage limits no longer show old readings after a failed probe. It follows the conventional commit form and matches the raw summary, which describes publishing probeFailed results directly instead of merging them with the previously published limits.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope and Verification sections, each with specific content. It explains the bug, links #34381 and #39544, gives a diff of the change, and lists the tests run with observed results. It also states what was not checked and records known limitations. It does not name the model and harness in the required way, but it does name Claude Code (Claude Opus 5.5) and the reviewers, which covers the agent-attribution line. The template asks for before/after evidence only for UI changes, and this change is server-side, so none is needed.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e5eab57 and 93e70cf.

Files selected for processing: 3

  • apps/server/src/provider/AntigravityProvider.test.ts
  • apps/server/src/provider/AntigravityProvider.ts
  • packages/provider-core/src/server/managedProvider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added takeover:in-progress A takeover lead is working on this PR takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 13, 2026

@surya-gorla surya-gorla 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.

I independently exercised this on an isolated Apple Silicon checkout (Node 26.12.1), including cherry-picking f2cac8d cleanly onto current upstream main (6bce222). The main CLI/ACP fix behaves as described, but I found one reachable edge case against the stated never show a different account's quota guarantee.

Unresolved executable can still read the stale profile token. The health check resolves the executable once, then triggers a separate asynchronous usage probe that resolves it again. If the executable/launcher disappears or becomes unresolvable between those two operations, credentialsInProfile starts as true (or retains a prior ACP true) and Effect.orElseSucceed(() => credentialsInProfile) permits reading acp_token.json even though we no longer know which runtime/account is selected. The current test deliberately expects four windows when resolution never succeeded, demonstrating the unsafe fallback.

I extended the existing antigravityUsageLimits.test.ts case to require windows: [], unavailable.reason: "unsupported", and zero token requests when (1) the first runtime lookup fails, or (2) a lookup fails after a successful ACP probe. The latter assertion fails on this PR as written: it returns four windows instead of none. It passes with a small fail-closed change:

const inProfile = yield* Effect.option(input.credentialsInProfile);
if (Option.isNone(inProfile)) {
  cached = undefined;
  return makeUnavailableUsageLimits({
    checkedAt,
    reason: "unsupported",
    message: "Antigravity limits are unavailable while its runtime cannot be resolved.",
  });
}
if (!inProfile.value) {
  // Existing CLI-unavailable branch
}

This also removes the mutable let credentialsInProfile = true fallback. The ACP runtime still shows quotas when resolvable; a transient unresolved runtime instead shows unavailable rather than potentially another account's quotas.

Local verification of the adjusted version: 24/24 focused Antigravity tests pass; vp run check:changed --concurrency 2 passes format, lint, both knip checks, GraphQL, affected-package typechecks (3 packages), and selected tests (26/26). I did not run a real CLI sign-in; neither agy nor ACP is installed on this Mac.

Separate CI gate: recent Agent Context Budget runs are red because this branch carries codexAdditionalContextBytes: 7327 while current main has 7324 (+3), even though this PR didn't change that file. Cherry-picking onto current main was conflict-free locally; updating the PR branch onto latest main should address that stale-base discrepancy. I would avoid the agent-context-increase override for this unrelated drift.

Thanks for the focused fix—these are the two things I found that still need attention before the existing PR can safely land.

@maria-rcks

maria-rcks commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

Partial runtime verification of f2cac8de51ccaf8af2cc332b40a91e5d5a7b595d on Linux, using Playwright with system Google Chrome. Ran vp i and isolated vp run dev servers for github/main (e0ca4fcecb) and the exact PR head, one at a time. Created a project pointing at the real checkout through the app. Installed genuine Antigravity runtimes through Settings > Providers, with no mocks or credential fixtures.

Selected the real 1.5.9 CLI executable through Binary path and refreshed provider status. The running server published zero quota windows and unsupported with Antigravity limits are unavailable when using the agy CLI. Switching to the installed 1.4.5 ACP runtime restored the normal unsigned-in result, Sign in with Google to see Antigravity limits. Switching back restored the CLI-specific result. On main, the CLI produced the generic sign-in result instead. These results were read from the running server's provider cache after the client actions.

Usage > Limits and Refresh limits showed no quota cards. The pooled view shows its generic empty state, rather than the probe's CLI-specific explanation. Real Codex gpt-6.1-sol first turns succeeded on both revisions; a follow-up also succeeded on the PR. Usage > Tokens still displayed real Codex usage. That scanner includes existing local provider sessions, so its totals are not a measurement of these verification turns.

blacksmith-check ran the existing antigravityUsageLimits.test.ts and AntigravityDriver.test.ts: 24 tests passed in 2 files. No source changes or pushes. CI currently has an Agent context budget failure; this is not an all-green claim.

Runtime transcript

Real Codex gpt-6.1-sol response on the PR head

Usage Tokens still displays real Codex usage

Not verified

The original wrong-account quota display could not be reproduced on main: this VM has no Google sign-in or leftover acp_token.json. The CLI guard was exercised without credentials; this does not prove the signed-in, stale-token scenario end to end. Signed-in ACP quota retrieval, account replacement/sign-out, and the executable-resolution race raised in the existing review remain unverified. Native desktop/mobile clients and macOS/Windows were not exercised.

@mths-mcfs
mths-mcfs marked this pull request as draft November 17, 2026 18:01
mths-mcfs and others added 2 commits November 17, 2026 15:01
The probe kept its last answer when the executable lookup failed, and
started from "ACP" before any lookup succeeded, so it could still read a
leftover profile token that belongs to another account. An unresolved
runtime now reports limits as unavailable and drops the cached token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mths-mcfs

Copy link
Copy Markdown
Author

Thanks @surya-gorla, both points are addressed in 5937e05.

  • An unresolved runtime now fails closed: the probe reports unsupported ("…while its runtime cannot be resolved."), drops the cached token, and makes no request. This also covers the case where no lookup has succeeded yet. The test has your two cases (first lookup fails; lookup fails after an ACP answer) plus the ACP recovery, which refreshes the token again. The ACP → failure step failed by assertion against the previous head.
  • The branch now has current main merged in (merge commit, no rebase), so Agent context budget should no longer see the stale baseline. I did not use the override label.

A further review found a race that this PR does not introduce: a probe that starts on ACP and finishes after the binary path is switched to the CLI still publishes that account's limits until the next probe. It is listed under "Known limitation" in the description, since fixing it belongs in how the provider publishes probe results, outside this fix.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 20, 2026
@mths-mcfs
mths-mcfs marked this pull request as draft November 20, 2026 19:18
mths-mcfs and others added 2 commits November 20, 2026 16:54
…sage-limits

# Conflicts:
#	apps/server/src/provider/antigravityUsageLimits.test.ts
#	apps/server/src/provider/antigravityUsageLimits.ts
…ailed probe

When the Antigravity quota read failed after a good one, Usage > Limits kept
showing the old windows as current. The provider now publishes the failed
read as it came, so clients show the failure notice. Other providers keep
the last good read, through a new managed-provider option whose default is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Nov 20, 2026
mths-mcfs and others added 2 commits November 20, 2026 17:31
…account's limits

Snapshot enrichment always put the last published usage limits back, so after
sign-out the stream still carried the old account's windows, and a failed read
briefly showed the old bars before the republish. The managed-provider option
becomes retainUsageLimits; with false, enrichment publishes the limits the
provider reports. Antigravity uses it; the default is unchanged.

The Antigravity test now subscribes before each trigger and waits for the
republish that follows each read, so it no longer depends on timing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mits

A health check could read the limits, wait, and then publish them after
enrichment had already published a newer read, so the old reading (or the
previous account's after sign-out) showed for a moment.

With retainUsageLimits: false, enrichment is now the only writer of limits:
a provider check keeps the published limits instead of applying the ones it
read. The health check Antigravity ran after each quota read only existed
to publish it, so it is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Nov 20, 2026
mths-mcfs and others added 5 commits November 20, 2026 18:37
…mits

A refresh bumps the enrichment generation, which retires the running
enrichment, and only then starts the next one. Interrupting the refresh in
between left no enrichment running, so for Antigravity, where enrichment is
the only writer of limits, finished quota reads never reached clients until
the next health check.

applySnapshotBase is now uninterruptible except for the provider check
itself, so a new generation always gets its enrichment fiber. The test for
stale check results also no longer depends on scheduler order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…order

The limits case waited on stream publishes, and nextPublish only subscribed
when first pulled, so a publish could land before the subscription. Each
read now resolves its own Deferred and the case asserts what the health
check that republishes a read publishes, read through a refresh queued
behind it. It no longer claims that sign-out clears the published limits.
nextPublish subscribes when called, and the onSignedIn comment matches the
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mths-mcfs mths-mcfs changed the title fix(antigravity): usage limits no longer show another account's quota with the agy CLI fix(server): Antigravity limits no longer show old readings after a failed probe Nov 20, 2026
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Nov 20, 2026
…moves back

The draft stored every quota read as-is, so a good read stamped before the
published one replaced it in getSnapshot while clients kept the newer one.
It now stores only a failed read as-is and otherwise keeps main's rule, like
the managed provider's check. The limits test also asserts what
streamChanges publishes for each read, ending at a command update it makes
afterwards, and covers the clock moving back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mths-mcfs

Copy link
Copy Markdown
Author

Thanks for the runtime check, @maria-rcks. Running main against the PR head with the real 1.4.5 and 1.5.9 runtimes was very useful. The branch has changed since f2cac8d: #39544 now fixes the credential order, so the unsupported guard for the agy CLI you exercised is gone. This PR now covers only the failed-probe case, where Antigravity shows the probe's error instead of keeping the previous limits as if they were current. The signed-in scenario you couldn't reproduce is still unverified here too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants