@estebanforge/pi-antigravity-bridge 1.10.8 → 1.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/provider.ts +16 -0
- package/src/quota-notice.ts +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.10.9] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Quota exhaustion settles as a retryable provider error instead of assistant text (issue #16).** When an Antigravity account's quota is spent, agy streams the quota notice ("⚠ Individual quota reached ... Resets in 153h38m14s") as plain agent text and ends the turn with `end_turn`, so the turn settled as a successful reply (`stopReason: "stop"`) and provider failover (pi-router, or any consumer keyed on pi's error classification) never fired. A text-only turn whose settled response matches the notice shape (anchored at the start, ≤400 chars, optional reset interval parsed out) now finalizes with `stopReason: "error"` and a retryable-classified message (`agy rate limit (ResourceExhausted): Antigravity quota exhausted; resets in ...`). The wording is load-bearing: pi-ai's `isRetryableAssistantError` gates failover and classifies "quota exceeded"/"billing" wording as fail-fast (no router handoff), so the message carries the retryable markers and never echoes the raw notice, keeping upstream copy drift from poisoning the classification. Turns that ran tools or produced thinking keep the normal reply, and the session binding is untouched (the conversation is healthy). Without a router, pi's built-in retry re-runs the same exhausted account within its retry budget - bounded, but expect repeat attempts until the reset lapses. Detection is content-based pending a structured upstream signal (none documented in ACP-PROTOCOL-REFERENCE.md; a live probe on an exhausted account would settle it).
|
|
10
|
+
|
|
5
11
|
## [1.10.8] - 2026-11-16
|
|
6
12
|
|
|
7
13
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estebanforge/pi-antigravity-bridge",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.9",
|
|
4
4
|
"description": "Gemini provider for Pi on the Antigravity ACP server (official Google ACP) or the stream-json agy CLI. Use antigravity/* models in Pi. Full /model picker support. Models runs Pi's tools. ToS safe to use.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/src/provider.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { toPiUsage } from "./stream-events.js";
|
|
|
40
40
|
import { mapAgyToolToNative } from "./native-tools.js";
|
|
41
41
|
import { toAgyEffort, type AgyModelEntry } from "./models.js";
|
|
42
42
|
import { SessionStore } from "./sessions.js";
|
|
43
|
+
import { detectQuotaNotice, quotaErrorMessage } from "./quota-notice.js";
|
|
43
44
|
import { loadConfig } from "./config.js";
|
|
44
45
|
import { GATE_MARKER, mapNativeToShadow, stripMarkerFields } from "./approval-gate.js";
|
|
45
46
|
import type { ApprovalDecision, ApprovalPayload, ApprovalParkApi } from "./mcp-server.js";
|
|
@@ -1605,6 +1606,8 @@ async function runTurnDriver(
|
|
|
1605
1606
|
// the cumulative task dir never re-reports older turns' logs.
|
|
1606
1607
|
const turnStartMs = Date.now();
|
|
1607
1608
|
let nativeBackgroundSeen = false;
|
|
1609
|
+
// Issue #16 guard: quota reclassification applies to text-only turns only.
|
|
1610
|
+
let sawToolOrThought = false;
|
|
1608
1611
|
const feats: ActivityFeatures = {
|
|
1609
1612
|
replay: deps.replay,
|
|
1610
1613
|
nativeActive: deps.nativeActive,
|
|
@@ -1622,6 +1625,7 @@ async function runTurnDriver(
|
|
|
1622
1625
|
for (;;) {
|
|
1623
1626
|
const activity = await h.next();
|
|
1624
1627
|
if (!activity) break;
|
|
1628
|
+
if (activity.type !== "text" && activity.type !== "usage") sawToolOrThought = true;
|
|
1625
1629
|
if (consumeActivity(stream, blocks, activity, diffCtx, cwd, feats) === "parked") return "parked";
|
|
1626
1630
|
}
|
|
1627
1631
|
};
|
|
@@ -1693,6 +1697,18 @@ async function runTurnDriver(
|
|
|
1693
1697
|
);
|
|
1694
1698
|
return;
|
|
1695
1699
|
}
|
|
1700
|
+
// Issue #16: agy streams the account quota notice as agent text and ends
|
|
1701
|
+
// the turn OK; settle it as a retryable error so provider failover fires.
|
|
1702
|
+
// Text-only turns only, and the binding is untouched below: the
|
|
1703
|
+
// conversation itself is healthy, unlike the silentDrop signature above.
|
|
1704
|
+
if (outcome.status === "OK" && !outcome.aborted && !sawToolOrThought) {
|
|
1705
|
+
const quota = detectQuotaNotice(outcome.response);
|
|
1706
|
+
if (quota) {
|
|
1707
|
+
deps.log?.("turn-error", { reason: "quota-exhausted", resetsIn: quota.resetsIn ?? null }, "error");
|
|
1708
|
+
finalize(stream, blocks, "error", quotaErrorMessage(quota));
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1696
1712
|
// Gap closer: the result landed while the turn was still live (reentry
|
|
1697
1713
|
// above), the turn ended, and the model never polled. Same strand, same
|
|
1698
1714
|
// fix: sweep and deliver as a late run in the same conversation. Single
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Quota-exhaustion notice detection (issue #16). agy streams the account's
|
|
2
|
+
// quota notice as plain agent text and ends the turn with end_turn, so the
|
|
3
|
+
// provider reclassifies the settled response into a pi error instead of a
|
|
4
|
+
// successful reply.
|
|
5
|
+
//
|
|
6
|
+
// The pi-side errorMessage wording is load-bearing: pi-ai's
|
|
7
|
+
// isRetryableAssistantError gates provider failover and classifies
|
|
8
|
+
// "quota exceeded" / "billing" wording as fail-fast (no router handoff), so
|
|
9
|
+
// the message must carry a retryable marker ("rate limit") while staying
|
|
10
|
+
// clear of every non-retryable pattern. The raw upstream notice is never
|
|
11
|
+
// echoed, so upstream copy drift cannot poison the classification.
|
|
12
|
+
|
|
13
|
+
/** Reset interval parsed from the notice, e.g. "153h38m14s". */
|
|
14
|
+
export interface QuotaNotice {
|
|
15
|
+
resetsIn?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Anchored at the start and length-capped so only a notice-shaped
|
|
19
|
+
// (near-)whole response reclassifies; a long answer that merely discusses
|
|
20
|
+
// quota must never match.
|
|
21
|
+
const NOTICE_PATTERN = /^\s*(?:⚠\s*)?(?:[a-z]+\s+)?quota\s+(?:reached|exhausted|exceeded|limit reached)/i;
|
|
22
|
+
const RESET_PATTERN = /resets?\s+in\s+((?:\d+h)?(?:\d+m)?(?:\d+s))/i;
|
|
23
|
+
const NOTICE_MAX_CHARS = 400;
|
|
24
|
+
|
|
25
|
+
/** Classify a settled driver response as a quota-exhaustion notice.
|
|
26
|
+
* Conservative by design: false negatives keep a normal reply, false
|
|
27
|
+
* positives would turn real answers into errors. */
|
|
28
|
+
export function detectQuotaNotice(response: string): QuotaNotice | undefined {
|
|
29
|
+
const trimmed = response.trim();
|
|
30
|
+
if (trimmed.length === 0 || trimmed.length > NOTICE_MAX_CHARS) return undefined;
|
|
31
|
+
if (!NOTICE_PATTERN.test(trimmed)) return undefined;
|
|
32
|
+
const resetsIn = RESET_PATTERN.exec(trimmed)?.[1];
|
|
33
|
+
return resetsIn ? { resetsIn } : {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Retryable-classified pi errorMessage for a detected notice. */
|
|
37
|
+
export function quotaErrorMessage(notice: QuotaNotice): string {
|
|
38
|
+
const reset = notice.resetsIn ? `; resets in ${notice.resetsIn}` : "";
|
|
39
|
+
return `agy rate limit (ResourceExhausted): Antigravity quota exhausted${reset}`;
|
|
40
|
+
}
|