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: classify Claude rolling usage limits

[._.]/ Adam Eivy0b77d9aa8ace
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 57a3f86990..823e1fe992 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -126,13 +126,17 @@ const ERROR_PATTERNS = [
},
{
// `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,
+ // quota banner (see AGY_QUOTA_BANNER). Claude Code reports its rolling
+ // subscription exhaustion as `You've hit your monthly spend limit ...
+ // your session limit resets ...`, which is a usage limit too even though it
+ // does not contain the older `usage limit` wording. The existing
+ // usage-limit category is also used by the immediate-fallback signals; the
+ // CLI path needs this post-hoc match to bench the provider and reach a
+ // fallback rather than falling through to UNKNOWN. Kept to vendor/billing
+ // phrasing — 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|hit your (?:monthly )?spend limit|your session limit resets?|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,
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index c8d0ba4251..c4f16c165c 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -94,6 +94,13 @@ describe('Error Detection', () => {
expect(result.requiresFallback).toBe(true);
});
+ it('should detect Claude Code rolling session limits reported as monthly spend', () => {
+ const result = analyzeError("You've hit your monthly spend limit · raise it at claude.ai/settings/usage?from=cc_cli_limit_message · your session limit resets 7:15am (UTC)", 1);
+ expect(result.hasError).toBe(true);
+ expect(result.category).toBe(ERROR_CATEGORIES.USAGE_LIMIT);
+ expect(result.requiresFallback).toBe(true);
+ });
+
it('should detect Claude extra-usage status as a usage limit', () => {
const result = analyzeError('Now using extra usage');
expect(result.hasError).toBe(true);