Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: detect agy's spent-quota banner so a dead provider stops passing as a successful run

[._.]/ Adam Eivy987b562e38fb
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 153c44df8d..dd2c5bf6b8 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -31,6 +31,8 @@
- A series' pinned image backend now actually renders its comic pages and covers. The pin was saved on the series and honoured by first-pass portraits, but the comic stage sent the install-wide default as an explicit choice — which outranks any pin — so a series pinned to one backend quietly rendered every page and cover on another. The Pipeline visuals default from Settings → Image Gen now applies to these renders too, and a pin naming a backend you have since turned off falls back instead of failing the render.
- Typing on the Shell page no longer doubles capital letters and spaces. `Hi There` arrived at the shell — or at a watched agent TUI — as `HHii TThere`, which made typing a message to a running agent unusable. The terminal forwards most printable keys on keydown and cancels the event there, but hands capitals and space to the browser's keypress default action, which then also fires an input event for the same character. The dictation bridge (which reads those input events to keep voice dictation from garbling) was translating that second event into a second keystroke; it now recognizes an insertion the keypress path already sent and leaves it alone. Voice dictation and soft-keyboard input, which arrive with no keypress behind them, are unaffected.
+- An Antigravity (agy) run that hits the account's subscription quota is now recognized as a spent quota instead of being recorded as a success. When the quota is gone agy paints `⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 3h51m14s.` where the answer would have been, and then goes silent — so the run's output-idle fallback finished it as a *successful* run whose "response" was the repainted prompt screen. Downstream that is worse than a failure: a Series Autopilot foundation-judge call read the JSON example out of its own echoed instructions, and the run died reporting "foundation judge response parsed but its rubric is incomplete or contains placeholders" — a manuscript problem, for what was purely an exhausted provider quota. Both attempts burned on the same dead provider, because nothing had marked it unavailable. PortOS now fails such a run the moment the banner appears, benches agy until its quota frees up, and lets the call retry on a fallback provider. CoS agent runs classify the same banner as a usage limit rather than an unknown error, so they stop re-picking the spent provider too.
+
- Two CoS agents running without a worktree can no longer steal each other's completion. Agents whose task needs no code change (the issue-filing and reasoning types) all run in the primary checkout, and every one of them wrote its done-signal to the same `.agent-done` file — so with two running at once the second overwrote the first's summary, and each run's 2-second poll finalized on whichever sentinel happened to be there, attributing one agent's result to the other and killing a session that was still working. The sentinel is now named per agent instance (`.agent-done-<agentId>`), resolved from one helper by every side that touches it — the path written into the agent's prompt, the 2-second poll, the durable runner's watch, the CLI exit check, the structured-payload read, and the worktree-cleanup ignore — so a run reads, cleans up, and reports only its own. A Layered Intelligence reasoning run, where that file *is* the deliverable, was also being handed two different filenames in one prompt; its instructions now defer to the sentinel path the briefing gives it. The one behaviour to know about on upgrade: an agent still mid-run when the server restarts was told the old shared name, so it finalizes through its normal idle/exit path rather than the sentinel poll.
## Changed
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 2d62291c33..1aac87eb0f 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -76,7 +76,14 @@ const ERROR_PATTERNS = [
suggestedFix: 'Wait and retry - temporary rate limiting'
},
{
- pattern: /(?:hit your usage limit|You've hit your limit|usage limit|Upgrade to Pro|(?:^|\n)\s*(?:\[stderr\]\s*)?Now using extra usage\s*(?:\r?\n|$))/i,
+ // `upgrade your subscription to increase your limits` is Antigravity's
+ // quota banner (see AGY_QUOTA_BANNER). Included here as well as in the
+ // immediate-fallback signals so the post-hoc output scan a FAILED run runs
+ // through `analyzeError` categorizes it as a usage limit and benches the
+ // provider, rather than falling through to UNKNOWN. Kept as the whole
+ // vendor sentence — a bare "quota reached" is a phrase story text can
+ // legitimately contain, and this scan reads the model's entire screen.
+ pattern: /(?:hit your usage limit|You've hit your limit|usage limit|Upgrade to Pro|upgrade your subscription to increase your limits|(?:^|\n)\s*(?:\[stderr\]\s*)?Now using extra usage\s*(?:\r?\n|$))/i,
category: ERROR_CATEGORIES.USAGE_LIMIT,
requiresFallback: true,
actionable: true,
@@ -138,7 +145,31 @@ const WAIT_TIME_PATTERNS = [
// to the detector as `[stderr] ${text}`, so it lands BEFORE the CLI's own gutter
// glyphs. The alternation lets tag and gutter interleave in either order —
// requiring gutter-then-tag would demote a genuine banner printed on stderr.
-const TUI_GUTTER_PREFIX = '^(?:[\\s│┃╎⎿⏺●•]|\\[stderr\\])*';
+// `⚠` is agy's gutter glyph for its own error banners (quota, see below).
+const TUI_GUTTER_PREFIX = '^(?:[\\s│┃╎⎿⏺●•⚠]|\\[stderr\\])*';
+
+// Antigravity's spent-subscription banner, as agy paints it:
+//
+// ⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 3h51m14s.
+// Error ID: <uuid>-7
+//
+// Line-anchored behind gutter decoration only, so an agent writing ABOUT the
+// banner (a markdown bullet, prose, a grep hit) never matches — the same
+// precision the `Now using extra usage` entry relies on. The qualifier before
+// `quota reached` is left open (`Individual` today) because it names WHOSE
+// quota, not what happened. `Resets in …` is optional: it is the part most
+// likely to change shape, and the sentence before it is already unambiguous.
+//
+// The trailing lookahead requires agy's `Error ID:` envelope line WITHOUT
+// pulling it into match[0], and that asymmetry is the point. `match[0]` becomes
+// the run's error string, which becomes the autopilot's failure reason, which a
+// CoS task description then quotes on a line of its own — and a TUI echoes a
+// pasted prompt indented, i.e. behind nothing but whitespace. Without the
+// lookahead this signal would match its OWN propagated message and kill the very
+// agent dispatched to investigate it. Keeping the envelope out of the capture
+// means the reason string can never re-match. A hypothetical banner agy prints
+// with no `Error ID:` is deliberately left to the post-hoc output scan below.
+const AGY_QUOTA_BANNER = `${TUI_GUTTER_PREFIX}(?:[A-Za-z][\\w-]*\\s+)?quota reached\\.\\s*Please upgrade your subscription to increase your limits\\.(?:\\s*Resets? in\\s*[^\\r\\n]{1,32})?(?=\\s{0,8}Error ID:)`;
/**
* Signals that fail a run immediately so the task can pick a fallback provider.
@@ -220,6 +251,42 @@ const IMMEDIATE_FALLBACK_SIGNALS = [
suggestedFix: 'Antigravity account verification is still in progress — sidelining the provider briefly and retrying on a fallback.',
actionable: false
},
+ {
+ // Antigravity REFUSES a submission outright once the account's subscription
+ // quota is spent: it paints the one-line banner above where the answer would
+ // have gone, empties the composer, and returns to its idle footer. Nothing
+ // further arrives — so the one-shot TUI runner's output-idle fallback fires
+ // and finalizes the run as `idle-complete` SUCCESS with the repainted PROMPT
+ // screen standing in for the response.
+ //
+ // That is worse than a lost run. On 2026-08-13 both attempts of a
+ // `pipeline-judge-foundation` call died this way (90KB and 284KB of screen
+ // scrape, `success: true`, `errorCategory: null`). The judge prompt carries a
+ // JSON output-contract example — `{ "score": 6, "gap": "string", "fix":
+ // "string" }` — so the judge parsed the placeholder rubric back out of its own
+ // echoed instructions, the shape guard rejected it (correctly), and the series
+ // autopilot died reporting "foundation judge response parsed but its rubric is
+ // incomplete or contains placeholders": a manuscript-shaped error for what was
+ // purely a spent provider quota.
+ //
+ // USAGE_LIMIT, not AUTH_ERROR: the account and the PortOS config are both
+ // fine. `actionable: false` (unlike the extra-usage entry below) because the
+ // banner states its own reset — blocking the task would strand an unattended
+ // run over a condition that needs no human and that a fallback provider can
+ // serve right now (see agentErrorAnalysis#resolveFailedTaskDecision).
+ // `graceMs` stays 0: hours is far past what a live session can wait out.
+ //
+ // `structuredMarker` mirrors the pattern rather than loosening it — the point
+ // here is the untrusted-slice-boundary guard in resolveSignalOrigin, so a
+ // `^` match fabricated by the rolling window fails the run without benching a
+ // healthy provider.
+ pattern: new RegExp(AGY_QUOTA_BANNER, 'im'),
+ structuredMarker: new RegExp(AGY_QUOTA_BANNER, 'im'),
+ category: ERROR_CATEGORIES.USAGE_LIMIT,
+ message: 'Antigravity subscription quota reached',
+ suggestedFix: 'Antigravity subscription quota is spent until it resets — sidelining the provider and retrying on a fallback.',
+ actionable: false
+ },
{
// No `structuredMarker`: this pattern has no loose alternative to gate. It
// already requires the vendor-branded status line to OWN a whole line, so a
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index 5554640601..e5edd29e2c 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -13,6 +13,12 @@ import {
ERROR_CATEGORIES
} from './errorDetection.js';
+// The banner line agy paints where a spent-quota answer would have gone,
+// ANSI-stripped exactly as captured from the runs that killed a series-autopilot
+// foundation gate on 2026-08-13. Real chrome always pairs it with an
+// `Error ID: <uuid>-<n>` line, which the signal requires but does not capture.
+const QUOTA_BANNER_LINE = '⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 3h51m14s.';
+
describe('Error Detection', () => {
describe('analyzeError', () => {
it('detects a Codex/OpenAI content-safety refusal', () => {
@@ -62,6 +68,16 @@ describe('Error Detection', () => {
expect(result.requiresFallback).toBe(true);
});
+ // The post-hoc scan a failed run runs through analyzeError must reach the
+ // same verdict as the in-stream signal, or the provider is never benched and
+ // the next dequeued call re-dies on the same spent quota.
+ it('should detect the Antigravity spent-quota banner as a usage limit', () => {
+ const result = analyzeError('⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 3h51m14s.', 1);
+ expect(result.hasError).toBe(true);
+ expect(result.category).toBe(ERROR_CATEGORIES.USAGE_LIMIT);
+ expect(result.requiresFallback).toBe(true);
+ });
+
it('should not detect ordinary prose about extra usage as a usage limit', () => {
const result = analyzeError('The report mentions extra usage in the appendix.', 1);
expect(result.hasError).toBe(true);
@@ -254,6 +270,81 @@ describe('Error Detection', () => {
expect(detectImmediateFallbackSignal('Now using extra usage\n')).toMatchObject({ graceMs: 0 });
});
+ // agy paints this INSTEAD of an answer and then goes quiet, so the one-shot
+ // TUI runner idle-completes the run as SUCCESS and hands the repainted
+ // prompt screen downstream as the model's response. Fixture is the
+ // ANSI-stripped shape captured from the runs that killed a series-autopilot
+ // foundation gate on 2026-08-13.
+ it('detects the Antigravity spent-quota banner', () => {
+ const rendered = ` \`\`\`\r\n\n${QUOTA_BANNER_LINE}\r\nError ID: 00000000-0000-4000-8000-000000000000-7\r\n`;
+ expect(detectImmediateFallbackSignal(rendered)).toMatchObject({
+ hasError: true,
+ category: ERROR_CATEGORIES.USAGE_LIMIT,
+ requiresFallback: true,
+ origin: 'provider',
+ // The banner names its own reset — no human has to do anything, and a
+ // fallback provider can serve the call right now. Blocking the task
+ // (resolveFailedTaskDecision) would strand an unattended run.
+ actionable: false,
+ // …but hours is far longer than a live session can profitably hold, so
+ // unlike the eligibility handshake this one fails over immediately.
+ graceMs: 0
+ });
+ });
+
+ it('carries the reset clause into the message so /runs shows when the quota frees up', () => {
+ expect(detectImmediateFallbackSignal(`${QUOTA_BANNER_LINE}\r\nError ID: 00000000-0000-4000-8000-000000000000-7\r\n`).message)
+ .toContain('Resets in 3h51m14s');
+ });
+
+ // The message becomes the run's error → the autopilot's failure reason → the
+ // body of the CoS task dispatched to investigate it, which a TUI echoes back
+ // indented (i.e. behind nothing but whitespace). If the signal matched its own
+ // propagated message it would kill that investigating agent on sight — which
+ // is why the `Error ID:` envelope is required but held OUT of the capture.
+ it('does not match the message it propagates, echoed back as prompt text', () => {
+ const propagated = detectImmediateFallbackSignal(`${QUOTA_BANNER_LINE}\r\nError ID: abc-7\r\n`).message;
+ expect(detectImmediateFallbackSignal(`### Context\n ${propagated}\n`)).toBeNull();
+ });
+
+ it('detects the quota banner without its optional reset clause', () => {
+ expect(detectImmediateFallbackSignal('⚠ Individual quota reached. Please upgrade your subscription to increase your limits.\nError ID: abc-7\n'))
+ .toMatchObject({ category: ERROR_CATEGORIES.USAGE_LIMIT, origin: 'provider' });
+ });
+
+ // Line-anchored behind gutter decoration only: an agent WRITING ABOUT the
+ // banner must not fail its own run, let alone bench a healthy provider.
+ it.each([
+ ['a markdown bullet in an agent write-up', `- ${QUOTA_BANNER_LINE}\nError ID: abc-7\n`],
+ ['prose quoting the banner', `The failure mode is "${QUOTA_BANNER_LINE}" — see errorDetection.js`],
+ ['a grep hit over a prior transcript', `data/runs/abc/output.txt:412: ${QUOTA_BANNER_LINE}\nError ID: abc-7\n`],
+ ['the banner with no agy error envelope behind it', `${QUOTA_BANNER_LINE}\nsome other line\n`],
+ ])('ignores a quoted quota banner (%s)', (_label, transcript) => {
+ expect(detectImmediateFallbackSignal(transcript)).toBeNull();
+ });
+
+ it('buffers the quota banner across stream chunks', () => {
+ const detect = createImmediateFallbackSignalDetector();
+ expect(detect('⚠ Individual quota reached. Please upgrade your ')).toBeNull();
+ // The envelope line lands in a later repaint than the banner itself.
+ expect(detect('subscription to increase your limits. Resets in 3h51m14s.\r\n')).toBeNull();
+ expect(detect('Error ID: 00000000-0000-4000-8000-000000000000-7\r\n'))
+ .toMatchObject({ category: ERROR_CATEGORIES.USAGE_LIMIT, origin: 'provider' });
+ });
+
+ // The rolling window's slice boundary matches `^…/m` too. The run still
+ // fails (its screen scrape is not an answer either way), but a fabricated
+ // line start must not be read as evidence about the provider's health.
+ it('does not promote a quota banner whose line start was fabricated by the window slice', () => {
+ // Size the window so the slice lands EXACTLY on the banner's first
+ // character: buffer[0] then looks like a line start the stream never
+ // witnessed, which is the only way `^…/m` can fire on quoted text.
+ const quoted = 'Individual quota reached. Please upgrade your subscription to increase your limits.\nError ID: abc-7\n';
+ const detect = createImmediateFallbackSignalDetector({ maxBuffer: quoted.length });
+ expect(detect(`while investigating I saw ${quoted}`))
+ .toMatchObject({ category: ERROR_CATEGORIES.USAGE_LIMIT, origin: 'output-scan' });
+ });
+
it('detects the Claude extra-usage status line', () => {
const result = detectImmediateFallbackSignal('Now using extra usage');
expect(result).toMatchObject({
diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.js
index fac7d333dd..419e0495c8 100644
--- a/server/services/agentErrorAnalysis.js
+++ b/server/services/agentErrorAnalysis.js
@@ -189,7 +189,7 @@ export const ERROR_PATTERNS = [
},
{
// Catches both "hit your usage limit" and session limits like "hit your limit · resets 6am"
- pattern: /(?:hit your (?:usage )?limit|usage.?limit|quota exceeded|Upgrade to Pro|plan.?limit|daily.?limit|session.?limit|\d+-hour limit reached|(?:^|\n)\s*(?:\[stderr\]\s*)?Now using extra usage\s*(?:\r?\n|$))/i,
+ pattern: /(?:hit your (?:usage )?limit|usage.?limit|quota exceeded|Upgrade to Pro|upgrade your subscription to increase your limits|plan.?limit|daily.?limit|session.?limit|\d+-hour limit reached|(?:^|\n)\s*(?:\[stderr\]\s*)?Now using extra usage\s*(?:\r?\n|$))/i,
category: 'usage-limit',
actionable: true, // Need to switch provider
// Promote only the distinctive provider-billing idioms (the matched
@@ -205,7 +205,16 @@ export const ERROR_PATTERNS = [
// same way. They stay distinctive enough that a task's own output does not
// trip them (unlike the bare `quota exceeded` / `plan limit` alternatives,
// which remain deliberately unpromoted).
- structuredMarker: /hit your (?:usage )?limit|(?:usage|session) limit reached|\d+-hour limit reached|Upgrade to Pro|Now using extra usage/i,
+ //
+ // Antigravity's `⚠ <Whose> quota reached. Please upgrade your subscription to
+ // increase your limits. Resets in 3h51m14s.` is the same case: the bare
+ // "quota reached" half is generic, but the upgrade sentence is vendor
+ // wording. WITHOUT it a spent agy subscription matched no alternative at
+ // all, stayed `unknown`, and left agy unbenched — so a series-autopilot run
+ // burned both foundation-judge attempts on the dead provider and reported the
+ // resulting screen scrape as a placeholder rubric (2026-08-13). The banner
+ // itself is caught in-stream by AGY_QUOTA_BANNER in aiToolkit/errorDetection.js.
+ structuredMarker: /hit your (?:usage )?limit|(?:usage|session) limit reached|\d+-hour limit reached|Upgrade to Pro|upgrade your subscription to increase your limits|Now using extra usage/i,
extract: (match, output) => {
const timeMatch = output.match(/(?:try again in|resets?)\s+(.+?)(?:\.|·|\n|$)/im);
const waitTime = timeMatch ? timeMatch[1].trim() : null;
diff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.js
index 7effae5bfe..0ff9270b5c 100644
--- a/server/services/agentErrorAnalysis.test.js
+++ b/server/services/agentErrorAnalysis.test.js
@@ -237,6 +237,21 @@ describe('analyzeAgentFailure — provenance origin (#2642)', () => {
expect(generic.origin).toBe('output-scan');
});
+ // A spent agy subscription used to match no usage-limit alternative at all
+ // ("quota reached" is not "quota exceeded", "your limits" is not "usage
+ // limit"), so it stayed `unknown` and agy was never benched — every
+ // subsequent dequeue re-picked the dead provider.
+ it('classifies and promotes the Antigravity spent-quota banner', () => {
+ const analysis = analyzeAgentFailure(
+ withLead('⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 3h51m14s.'),
+ { id: 't' },
+ 'x'
+ );
+ expect(analysis.category).toBe('usage-limit');
+ expect(analysis.origin).toBe('provider');
+ expect(analysis.requiresFallback).toBe(true);
+ });
+
it('stamps output-scan on model-not-supported (indistinguishable from a test asserting the phrase)', () => {
const analysis = analyzeAgentFailure(withLead("The 'gpt-5' model is not supported when using Codex with a ChatGPT account."), { id: 't' }, 'gpt-5');
expect(analysis.category).toBe('model-not-supported');