From 30b3a9de30674d3f860dc9f5f9412dfa474dc124 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 16 Jan 2026 09:39:09 +0000 Subject: [PATCH] fix: drop oauth status from session status --- .../clawdbot-tools.session-status.test.ts | 1 + src/agents/tools/session-status-tool.ts | 84 +++---------------- 2 files changed, 14 insertions(+), 71 deletions(-) diff --git a/src/agents/clawdbot-tools.session-status.test.ts b/src/agents/clawdbot-tools.session-status.test.ts index f3a07b7e2..c361f59d6 100644 --- a/src/agents/clawdbot-tools.session-status.test.ts +++ b/src/agents/clawdbot-tools.session-status.test.ts @@ -99,6 +99,7 @@ describe("session_status tool", () => { expect(details.ok).toBe(true); expect(details.statusText).toContain("Clawdbot"); expect(details.statusText).toContain("🧠 Model:"); + expect(details.statusText).not.toContain("OAuth/token status"); }); it("errors for unknown session keys", async () => { diff --git a/src/agents/tools/session-status-tool.ts b/src/agents/tools/session-status-tool.ts index c5df85f59..ab8114982 100644 --- a/src/agents/tools/session-status-tool.ts +++ b/src/agents/tools/session-status-tool.ts @@ -1,6 +1,5 @@ import { Type } from "@sinclair/typebox"; import { resolveAgentDir } from "../../agents/agent-scope.js"; -import { buildAuthHealthSummary, formatRemainingShort } from "../../agents/auth-health.js"; import { ensureAuthProfileStore, resolveAuthProfileDisplayLabel, @@ -32,7 +31,6 @@ import { formatUsageWindowSummary, loadProviderUsageSummary, resolveUsageProviderId, - type UsageProviderId, } from "../../infra/provider-usage.js"; import { buildAgentMainSessionKey, @@ -283,49 +281,33 @@ export function createSessionStatusTool(opts?: { defaultModel: DEFAULT_MODEL, }); const providerForCard = resolved.entry.providerOverride?.trim() || configured.provider; - const authStore = ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }); - const authHealth = buildAuthHealthSummary({ - store: authStore, - cfg, - }); - const oauthProfiles = authHealth.profiles.filter( - (profile) => profile.type === "oauth" || profile.type === "token", - ); - - const usageProviders = Array.from( - new Set( - oauthProfiles - .map((profile) => resolveUsageProviderId(profile.provider)) - .filter((provider): provider is UsageProviderId => Boolean(provider)), - ), - ); - const usageByProvider = new Map(); - if (usageProviders.length > 0) { + const usageProvider = resolveUsageProviderId(providerForCard); + let usageLine: string | undefined; + if (usageProvider) { try { const usageSummary = await loadProviderUsageSummary({ timeoutMs: 3500, - providers: usageProviders, + providers: [usageProvider], agentDir, }); - for (const snapshot of usageSummary.providers) { + const snapshot = usageSummary.providers.find( + (entry) => entry.provider === usageProvider, + ); + if (snapshot) { const formatted = formatUsageWindowSummary(snapshot, { now: Date.now(), maxWindows: 2, includeResets: true, }); - if (formatted) usageByProvider.set(snapshot.provider, formatted); + if (formatted && !formatted.startsWith("error:")) { + usageLine = `📊 Usage: ${formatted}`; + } } } catch { // ignore } } - const usageProvider = resolveUsageProviderId(providerForCard); - const usageLine = - oauthProfiles.length === 0 && usageProvider && usageByProvider.has(usageProvider) - ? `📊 Usage: ${usageByProvider.get(usageProvider)}` - : undefined; - const isGroup = resolved.entry.chatType === "group" || resolved.entry.chatType === "room" || @@ -371,53 +353,13 @@ export function createSessionStatusTool(opts?: { includeTranscriptUsage: false, }); - const authStatusLines = (() => { - if (oauthProfiles.length === 0) return []; - const formatStatus = (status: string) => { - if (status === "ok") return "ok"; - if (status === "static") return "static"; - if (status === "expiring") return "expiring"; - if (status === "missing") return "unknown"; - return "expired"; - }; - const profilesByProvider = new Map(); - for (const profile of oauthProfiles) { - const current = profilesByProvider.get(profile.provider); - if (current) current.push(profile); - else profilesByProvider.set(profile.provider, [profile]); - } - const lines: string[] = ["OAuth/token status"]; - for (const [provider, profiles] of profilesByProvider) { - const usageKey = resolveUsageProviderId(provider); - const usage = usageKey ? usageByProvider.get(usageKey) : undefined; - const usageSuffix = usage ? ` — usage: ${usage}` : ""; - lines.push(`- ${provider}${usageSuffix}`); - for (const profile of profiles) { - const labelText = profile.label || profile.profileId; - const status = formatStatus(profile.status); - const expiry = - profile.status === "static" - ? "" - : profile.expiresAt - ? ` expires in ${formatRemainingShort(profile.remainingMs)}` - : " expires unknown"; - const source = profile.source !== "store" ? ` (${profile.source})` : ""; - lines.push(` - ${labelText} ${status}${expiry}${source}`); - } - } - return lines; - })(); - - const fullStatusText = - authStatusLines.length > 0 ? `${statusText}\n\n${authStatusLines.join("\n")}` : statusText; - return { - content: [{ type: "text", text: fullStatusText }], + content: [{ type: "text", text: statusText }], details: { ok: true, sessionKey: resolved.key, changedModel, - statusText: fullStatusText, + statusText, }, }; },