From 922ca2ee1ccb7cc00f6c9fd7252a1c41de77710e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 9 Jan 2026 14:52:07 +0000 Subject: [PATCH] fix(status): surface provider usage errors --- src/auto-reply/reply/commands.ts | 9 +++++++++ src/infra/provider-usage.ts | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply/commands.ts b/src/auto-reply/reply/commands.ts index 222fb9081..65a36f203 100644 --- a/src/auto-reply/reply/commands.ts +++ b/src/auto-reply/reply/commands.ts @@ -153,6 +153,15 @@ export async function buildStatusReply(params: { agentDir: statusAgentDir, }); usageLine = formatUsageSummaryLine(usageSummary, { now: Date.now() }); + if ( + !usageLine && + (resolvedVerboseLevel === "on" || resolvedElevatedLevel === "on") + ) { + const entry = usageSummary.providers[0]; + if (entry?.error) { + usageLine = `📊 Usage: ${entry.displayName} (${entry.error})`; + } + } } } catch { usageLine = null; diff --git a/src/infra/provider-usage.ts b/src/infra/provider-usage.ts index c5bc53a4f..8d840a306 100644 --- a/src/infra/provider-usage.ts +++ b/src/infra/provider-usage.ts @@ -296,6 +296,9 @@ async function fetchClaudeUsage( { headers: { Authorization: `Bearer ${token}`, + "User-Agent": "clawdbot", + Accept: "application/json", + "anthropic-version": "2023-06-01", "anthropic-beta": "oauth-2025-04-20", }, }, @@ -304,11 +307,22 @@ async function fetchClaudeUsage( ); if (!res.ok) { + let message: string | undefined; + try { + const data = (await res.json()) as { + error?: { message?: unknown } | null; + }; + const raw = data?.error?.message; + if (typeof raw === "string" && raw.trim()) message = raw.trim(); + } catch { + // ignore parse errors + } + const suffix = message ? `: ${message}` : ""; return { provider: "anthropic", displayName: PROVIDER_LABELS.anthropic, windows: [], - error: `HTTP ${res.status}`, + error: `HTTP ${res.status}${suffix}`, }; }