alvin-bot 4.18.3 β 4.18.4
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 +24 -0
- package/dist/providers/claude-sdk-provider.js +49 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Alvin Bot are documented here.
|
|
4
4
|
|
|
5
|
+
## [4.18.4] β 2026-04-23
|
|
6
|
+
|
|
7
|
+
### π Critical fix: detect Anthropic quota-exhausted responses
|
|
8
|
+
|
|
9
|
+
**Problem:** When a Claude Max subscription runs out of weekly limit or extra-usage credits, Anthropic's gateway responds to every query with a short text chunk like *"You're out of extra usage Β· resets 9pm (Europe/Berlin)"* β delivered as `output_tokens=0`. The SDK surfaces it as a normal assistant text message. The bot has no way to distinguish it from a real Claude response, so one of two things happens:
|
|
10
|
+
|
|
11
|
+
1. The text passes through unchanged and the user sees the raw quota message as if it were Claude's reply.
|
|
12
|
+
2. The text is filtered downstream (some legacy paths) and the user sees `"(Keine Antwort)"` with zero explanation.
|
|
13
|
+
|
|
14
|
+
Both outcomes hide the real cause (credits) and every retry attempt wastes more credits on nothing.
|
|
15
|
+
|
|
16
|
+
**Symptoms observed on 2026-04-23:**
|
|
17
|
+
- User activates `/extra-usage`, sends query β `(Keine Antwort)` or raw limit text.
|
|
18
|
+
- Assumes bot / workspace / token is broken, spends hours debugging.
|
|
19
|
+
- Actual cause: extra-usage quota silently exhausted mid-debug-session.
|
|
20
|
+
|
|
21
|
+
**Fix** (`src/providers/claude-sdk-provider.ts`):
|
|
22
|
+
|
|
23
|
+
- New `isQuotaLimitOutput(text)` detects the Anthropic-gateway quota signatures (multiple English/German variants: "out of extra usage", "weekly usage limit", "rate limit exceeded", "quota exceeded", etc.).
|
|
24
|
+
- In the SDK stream loop: when the first text chunk matches this pattern, rewrite it as a clear actionable hint (*"β οΈ β¦Top up the plan or wait for the resetβ¦"*) AND invalidate the availability cache so the next heartbeat re-probes β but do NOT yield an `error` chunk (that would trigger fallback-cascade to Ollama and waste more credits on retries).
|
|
25
|
+
- In `isAvailable()`: the heartbeat probe now treats quota-exhausted output as "unavailable" in the same way it treats auth errors. Provider is marked unhealthy, bot stops trying until the next probe succeeds.
|
|
26
|
+
|
|
27
|
+
**Net effect:** bot no longer silently wastes credits after a quota limit is hit. Users see a plain, actionable message pointing at the right fix.
|
|
28
|
+
|
|
5
29
|
## [4.18.3] β 2026-04-23
|
|
6
30
|
|
|
7
31
|
### π Hotfix: 4.18.2 triggered unwanted failover to Ollama
|
|
@@ -25,6 +25,34 @@ export function isAuthErrorOutput(text) {
|
|
|
25
25
|
return false;
|
|
26
26
|
return /^\s*not logged in\b/i.test(text);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Detects Anthropic's rate-limit / quota-exhausted gateway responses.
|
|
30
|
+
* These are NOT model outputs β they come back as a single text chunk with
|
|
31
|
+
* output_tokens = 0 before the model even sees the prompt. Without this
|
|
32
|
+
* detection, the bot would forward the gateway message as if it were the
|
|
33
|
+
* assistant's reply ("(Keine Antwort)" or the raw quota text), masking the
|
|
34
|
+
* real cause and wasting more calls on retries.
|
|
35
|
+
*
|
|
36
|
+
* Covers the observed variants:
|
|
37
|
+
* - "You're out of extra usage Β· resets 9pm (Europe/Berlin)"
|
|
38
|
+
* - "You've reached your weekly usage limit. β¦"
|
|
39
|
+
* - "Rate limit exceeded"
|
|
40
|
+
* - Claude Max / Pro quota messages in both EN/DE
|
|
41
|
+
*/
|
|
42
|
+
export function isQuotaLimitOutput(text) {
|
|
43
|
+
if (!text)
|
|
44
|
+
return false;
|
|
45
|
+
const t = text.trim();
|
|
46
|
+
if (t.length === 0)
|
|
47
|
+
return false;
|
|
48
|
+
return (/you['β]re out of extra usage/i.test(t) ||
|
|
49
|
+
/reached (your |the )?(weekly |monthly |daily )?(usage|rate) limit/i.test(t) ||
|
|
50
|
+
/rate[- ]?limit(ed)? (exceeded|reached)/i.test(t) ||
|
|
51
|
+
/quota exceeded/i.test(t) ||
|
|
52
|
+
/usage limit reached/i.test(t) ||
|
|
53
|
+
/limit (reached|hit) for (this|your) (week|month|day)/i.test(t) ||
|
|
54
|
+
/resets? \d{1,2}(am|pm|:)/i.test(t) && /usage|limit/i.test(t));
|
|
55
|
+
}
|
|
28
56
|
const BOT_PROJECT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
29
57
|
// Load CLAUDE.md once at startup
|
|
30
58
|
let botClaudeMd = "";
|
|
@@ -198,6 +226,24 @@ export class ClaudeSDKProvider {
|
|
|
198
226
|
};
|
|
199
227
|
return;
|
|
200
228
|
}
|
|
229
|
+
// v4.18.4 β Guard against Anthropic rate-limit / quota-exhausted
|
|
230
|
+
// gateway messages that also arrive as a single text chunk (with
|
|
231
|
+
// output_tokens = 0). Pass them through as a friendly text chunk
|
|
232
|
+
// (NOT an error β would trigger fallback cascade to Ollama) and
|
|
233
|
+
// mark the provider as degraded so the next heartbeat re-checks.
|
|
234
|
+
if (!accumulatedText && isQuotaLimitOutput(block.text)) {
|
|
235
|
+
const hint = "β οΈ " + block.text.trim() +
|
|
236
|
+
"\n\nTop up the plan or wait for the reset. No message was sent to Claude.";
|
|
237
|
+
this.invalidateAvailabilityCache();
|
|
238
|
+
yield {
|
|
239
|
+
type: "text",
|
|
240
|
+
text: hint,
|
|
241
|
+
delta: hint,
|
|
242
|
+
sessionId: capturedSessionId,
|
|
243
|
+
};
|
|
244
|
+
accumulatedText = hint;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
201
247
|
accumulatedText += block.text;
|
|
202
248
|
yield {
|
|
203
249
|
type: "text",
|
|
@@ -411,7 +457,9 @@ export class ClaudeSDKProvider {
|
|
|
411
457
|
// sniff-stdout approach for backward compat.
|
|
412
458
|
try {
|
|
413
459
|
const { stdout: probeOut } = await execFileAsync(claudePath, ["-p", "ping", "--output-format", "text"], { timeout: 15000 });
|
|
414
|
-
|
|
460
|
+
// v4.18.4 β treat quota-exhausted as "unavailable" so heartbeat
|
|
461
|
+
// surfaces it and stops wasting extra-usage credits on retries.
|
|
462
|
+
return cache(!isAuthErrorOutput(probeOut) && !isQuotaLimitOutput(probeOut));
|
|
415
463
|
}
|
|
416
464
|
catch {
|
|
417
465
|
// Both checks failed β treat as unavailable
|