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: only bench a provider when a fallback-signal banner is real chrome, not agent-printed text (#3631)

[._.]/ Adam Eivy74848b0a403d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c63127a011..5ef164ddb3 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -15,3 +15,4 @@
- CoS agents whose deliverable is a **commit** are no longer scored as failures. The idle reaper's "did this agent do anything?" gate read only *uncommitted* changes, so a `/do:release` or `/do:pr` run that committed, pushed, and opened its PR — leaving a clean tree *because it succeeded* — was recorded as `idle-no-changes` and retried. Two consecutive release runs on 2026-08-08 each did their whole job (cut the release commit, opened the release PR, then repaired it against review findings) and were both reported failed, holding the release for two days. The gate now counts commits made inside the run window as evidence of work, alongside a dirty tree. The report-shaped half of the same problem (`/do:review`, `/do:scan`, `/do:plan-task`, `/do:replan`, whose deliverable lands outside the repo) is tracked in #3636, and the unsatisfiable `[task-<id>]` success criterion one layer up in #3637.
- Green merge-only PRs are drained on a real 30-minute cadence again. The pending-merge sweep had moved onto the CoS evaluation pass, but evaluation is event-driven — there is no evaluation timer — so on a quiet install it ran roughly once per PortOS restart, and the `MAX_PENDING_MERGE_TICKS` escape hatch counted restarts instead of the six hours it documents. The sweep now owns a `cos-pending-merge-sweep` interval job registered and cancelled with the other CoS timers, gated on the same "CoS auto-run is `execute` and not paused" switch. It stays decoupled from the `pr-watcher` task type, so leaving that task disabled still can't strand a queued merge, and `POST /api/cos/evaluate` still drains opportunistically.
+- An agent that merely *prints* a provider banner no longer benches a healthy provider. The immediate-fallback detector stamped every match as provider chrome, so a CoS agent that quoted Antigravity's account-eligibility banner — investigating that failure mode, `cat`-ing a prior run's transcript, grepping for it — sidelined the provider for the full cooldown across every subsequently dequeued task, not just its own run. The banner is now promoted to provider provenance only when it opens its own line behind nothing but TUI gutter chrome, the shape the CLI actually renders; a quoted mention still fails that one run and routes it to a fallback, but is no longer treated as evidence about the provider's health. Real banners arriving as the run's own terminal output bench exactly as before.
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 894c7c7b39..ca82b307e0 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -103,6 +103,29 @@ const WAIT_TIME_PATTERNS = [
/(\d+\s*day(?:s)?)?[,\s]*(\d+\s*hour(?:s)?)?[,\s]*(\d+\s*min(?:ute)?(?:s)?)?/i
];
+// TUI chrome renders a banner in an output gutter — leading whitespace plus the
+// box-drawing/bullet glyphs the CLIs draw (agy uses `⎿`, Claude Code `⏺`). An
+// agent *quoting* a banner in prose, a grep hit (`file.js:122: …`), or a source
+// line (`pattern: /…/`) puts real text before the banner on the same line, which
+// this prefix deliberately does NOT admit. Markdown list bullets (`- `, `* `) are
+// left out for the same reason: that is how an agent writes ABOUT a banner.
+const TUI_GUTTER_PREFIX = '^[\\s│┃╎⎿⏺●•]*(?:\\[stderr\\]\\s*)?';
+
+/**
+ * Signals that fail a run immediately so the task can pick a fallback provider.
+ *
+ * Provenance (#3631): a match is stamped `origin: 'provider'` — the whole gate
+ * `agentFinalization.js` uses to BENCH the provider for every subsequently
+ * dequeued task — only when the text is unambiguous provider chrome. When an
+ * entry's `pattern` can also match text the agent itself could have printed
+ * (quoting a banner in prose, `cat`-ing a prior run's `output.txt`, a grep hit
+ * over this file), an optional `structuredMarker` sub-pattern gates the
+ * promotion: without the marker the match falls through to
+ * `origin: 'output-scan'` — still a real failure that fails the run and routes
+ * to a fallback, just not evidence about the provider's health. This mirrors
+ * `resolvePatternOrigin` in PortOS's `agentErrorAnalysis.js`. An entry whose
+ * pattern has no loose alternative may omit `structuredMarker`.
+ */
const IMMEDIATE_FALLBACK_SIGNALS = [
{
// Antigravity leaves its composer visible while Google verifies account
@@ -120,12 +143,24 @@ const IMMEDIATE_FALLBACK_SIGNALS = [
// so that retry resolves onto a fallback rather than re-dying on the same
// banner three seconds later.
pattern: /We're finishing verifying your account eligibility\.\s*This usually takes a moment\. Please try again shortly\./i,
+ // The banner sentence is distinctive, but it is not chrome-ONLY: it matches
+ // anywhere in the stream, so an agent that merely quotes it (investigating
+ // this very failure mode, `cat`-ing a prior run's output, a grep hit over
+ // this file) used to bench a healthy provider for the full auth cooldown
+ // across every subsequently dequeued task (#3631). Promote to provider
+ // origin only when the banner opens its own line behind nothing but TUI
+ // gutter decoration — the shape agy actually renders.
+ structuredMarker: new RegExp(`${TUI_GUTTER_PREFIX}We're finishing verifying your account eligibility\\.`, 'im'),
category: ERROR_CATEGORIES.AUTH_ERROR,
message: 'Antigravity account eligibility is still being verified',
suggestedFix: 'Antigravity account verification is still in progress — sidelining the provider briefly 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
+ // quoted mention inside surrounding agent output never matches in the first
+ // place and the provider is left available (#3631).
pattern: /^\s*(?:\[stderr\]\s*)?Now using extra usage\s*(?:\r?\n|$)/im,
category: ERROR_CATEGORIES.USAGE_LIMIT,
message: 'Provider switched to extra usage',
@@ -260,6 +295,23 @@ export function analyzeError(errorText, exitCode = null) {
};
}
+/**
+ * Resolve the provenance origin for a matched IMMEDIATE_FALLBACK_SIGNAL (#3631).
+ * Returns `'provider'` only when the signal declares no `structuredMarker` (its
+ * pattern is chrome-only on its own) or that marker appears in the text;
+ * otherwise `'output-scan'` — a genuine failure that still requires a fallback,
+ * but not evidence the provider is unhealthy.
+ *
+ * The marker is tested against the WHOLE buffered text rather than the matched
+ * substring, mirroring `resolvePatternOrigin` in `agentErrorAnalysis.js`: a
+ * pattern returns its LEFTMOST match, which may be a quoted mention even when
+ * the real banner arrives later in the same buffer. Pure.
+ */
+function resolveSignalOrigin(signal, text) {
+ if (signal.structuredMarker && !signal.structuredMarker.test(text || '')) return 'output-scan';
+ return 'provider';
+}
+
export function detectImmediateFallbackSignal(text) {
if (!text) return null;
const value = String(text);
@@ -279,10 +331,9 @@ export function detectImmediateFallbackSignal(text) {
// signal opts out when the provider says the condition clears on its own.
actionable: signal.actionable !== false,
suggestedFix: signal.suggestedFix,
- // These banners are provider CHROME, not text an agent could have printed
- // — the host benches the provider on a provider-origin failure, so saying
- // so here is what routes the retry to a fallback (agentFinalization.js).
- origin: 'provider'
+ // Provider CHROME benches the provider host-side; text the agent itself
+ // could have printed must not (#3631). See resolveSignalOrigin.
+ origin: resolveSignalOrigin(signal, value)
};
}
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index f7650e1d8e..af9eae7cc7 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -160,6 +160,38 @@ describe('Error Detection', () => {
});
});
+ // #3631: the banner sentence matches anywhere in the stream, so an agent that
+ // merely QUOTES it still fails its own run — but it must not be read as
+ // evidence about the provider's health, or one such transcript benches a
+ // healthy provider for every subsequently dequeued task.
+ it.each([
+ ['prose that quotes the banner', "The known failure mode is: We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly. — see errorDetection.js"],
+ ['a grep hit over a prior run\'s transcript', "data/cos/agents/agent-1/output.txt:412: ⎿ We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly."],
+ ['a markdown bullet in an agent write-up', "- We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly.\n"],
+ ])('marks a quoted eligibility banner as output-scan (%s)', (_label, transcript) => {
+ const result = detectImmediateFallbackSignal(transcript);
+ expect(result).toMatchObject({
+ hasError: true,
+ category: ERROR_CATEGORIES.AUTH_ERROR,
+ // Still a real failure that routes to a fallback — just not provider chrome.
+ requiresFallback: true,
+ origin: 'output-scan'
+ });
+ });
+
+ it('still promotes the banner when it opens its own line behind TUI gutter chrome', () => {
+ const rendered = "reading the task brief…\n ⎿ We're finishing verifying your account eligibility.\n This usually takes a moment. Please try again shortly.\r\n";
+ expect(detectImmediateFallbackSignal(rendered)).toMatchObject({
+ category: ERROR_CATEGORIES.AUTH_ERROR,
+ origin: 'provider'
+ });
+ });
+
+ it('promotes a real banner that arrives later in a buffer whose earlier mention is quoted', () => {
+ const transcript = "I will check whether We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly. is still firing.\n⎿ We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly.\n";
+ expect(detectImmediateFallbackSignal(transcript)).toMatchObject({ origin: 'provider' });
+ });
+
it('buffers an Antigravity account-eligibility block across stream chunks', () => {
const detect = createImmediateFallbackSignalDetector();
expect(detect("We're finishing verifying your account eligibility. This usually ")).toBeNull();
@@ -181,6 +213,10 @@ describe('Error Detection', () => {
expect(result.actionable).toBe(true);
});
+ it('stamps the real extra-usage status line as provider chrome', () => {
+ expect(detectImmediateFallbackSignal('Now using extra usage\n')).toMatchObject({ origin: 'provider' });
+ });
+
it('does not match quoted prompt text in the middle of a line', () => {
const result = detectImmediateFallbackSignal('The failure condition is "Now using extra usage".');
expect(result).toBeNull();
diff --git a/server/services/agentFinalization.providerBench.test.js b/server/services/agentFinalization.providerBench.test.js
index da5bdf9c64..34709e9d65 100644
--- a/server/services/agentFinalization.providerBench.test.js
+++ b/server/services/agentFinalization.providerBench.test.js
@@ -109,6 +109,45 @@ describe('finalizeAgent provider sidelining', () => {
expect(markProviderUsageLimitMock).not.toHaveBeenCalled();
});
+ // #3631, the broad half of the same gate: `detectImmediateFallbackSignal` used to
+ // stamp `origin: 'provider'` unconditionally, so an agent that merely PRINTED one
+ // of these banners benched a healthy provider for every subsequently dequeued
+ // task. These drive the REAL detector — hand-stamping `origin` is exactly how the
+ // sibling regression shipped green.
+ it.each([
+ ['prose quoting the banner', "The known failure mode is: We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly. — see errorDetection.js"],
+ ['a grep hit over a prior run\'s transcript', "data/cos/agents/agent-1/output.txt:412: ⎿ We're finishing verifying your account eligibility. This usually takes a moment. Please try again shortly."],
+ // The extra-usage status line has no loose alternative — quoting it inline
+ // does not even register as a signal, so there is nothing to bench on.
+ ['a quoted extra-usage status line', 'the tail showed "Now using extra usage" in a prior run'],
+ ])('does not bench when the agent merely printed the banner (%s)', async (_label, transcript) => {
+ const analysis = detectImmediateFallbackSignal(transcript);
+ expect(analysis?.origin ?? null).not.toBe('provider');
+ await failedRun(analysis);
+ expect(markProviderUnavailableMock).not.toHaveBeenCalled();
+ expect(markProviderUsageLimitMock).not.toHaveBeenCalled();
+ });
+
+ it('still benches when the eligibility banner arrives as the run\'s own terminal output', async () => {
+ const analysis = detectImmediateFallbackSignal(
+ "starting the task…\n ⎿ We're finishing verifying your account eligibility.\n This usually takes a moment. Please try again shortly.\r\n"
+ );
+ expect(analysis).toMatchObject({ category: 'auth-error', origin: 'provider' });
+ await failedRun(analysis);
+ expect(markProviderUnavailableMock).toHaveBeenCalledWith('antigravity-tui', expect.objectContaining({
+ reason: 'auth-error',
+ }));
+ });
+
+ it('still benches on the real extra-usage status line', async () => {
+ const analysis = detectImmediateFallbackSignal('Now using extra usage\n');
+ expect(analysis).toMatchObject({ category: 'usage-limit', origin: 'provider' });
+ await failedRun(analysis, 'claude-code-tui');
+ expect(markProviderUsageLimitMock).toHaveBeenCalledWith('claude-code-tui', expect.objectContaining({
+ category: 'usage-limit',
+ }));
+ });
+
// The provenance gate is only as good as what `analyzeAgentFailure` promotes to
// `origin: 'provider'`. The case above hand-stamps that origin, which is exactly
// how a real regression shipped green: Claude Code's actual banners classified as