Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(advisor): print the metered-key login warning once per Claude member

Jack Rudenko1a0776bb7bc2
diff --git a/ai-docs/architecture/advisor.md b/ai-docs/architecture/advisor.md
index 6654ba06..d2ea5392 100644
--- a/ai-docs/architecture/advisor.md
+++ b/ai-docs/architecture/advisor.md
@@ -591,8 +591,9 @@ call. `index.ts` applies `effectiveCollector` to the config before `createProxyS
Runtime warnings are only for what the child decides:
- one `[advisor]` warning per call in which a model failed;
-- one warning when a Claude call cannot use the bearer the request carried, or the request
- carried none, and signs with a metered key instead;
+- one warning per launch per Claude member when a call cannot use the bearer the request
+ carried, or the request carried none, and signs with a metered key instead (every request of
+ such a launch gives the same answer; each call's record still carries `loginSkipped`);
- one warning per change when a routed call is served by a hop whose billing differs from the
notice's (stickiness, above);
- one warning per unrecorded call (S10);
diff --git a/packages/cli/src/handlers/native-handler-advisor.ts b/packages/cli/src/handlers/native-handler-advisor.ts
index f394a4a6..65e38d60 100644
--- a/packages/cli/src/handlers/native-handler-advisor.ts
+++ b/packages/cli/src/handlers/native-handler-advisor.ts
@@ -2110,6 +2110,21 @@ function claudeAdvisorRequestInit(
};
}
+/**
+ * The Claude members (`"<role>:<spec>"`) that have already printed the
+ * "cannot use the bearer / no bearer, signing with a metered key" warning.
+ * Every request of a launch whose login is skipped (a Console-key login, say)
+ * gives the same answer, so the line is printed once per launch per member,
+ * not once per advisor call. The per-call record still carries
+ * `loginSkipped` and the arm.
+ */
+const claudeAuthWarned = new Set<string>();
+
+/** Test seam: let every Claude member warn again. */
+export function _debug_resetClaudeAuthWarnings(): void {
+ claudeAuthWarned.clear();
+}
+
/**
* One Claude advisor call. Never rejects. The URL is the module constant
* `ANTHROPIC_MESSAGES_URL` and cannot be changed by the caller, so the login
@@ -2138,7 +2153,11 @@ export async function runClaudeAdvisorCall(
...(auth.facts.loginSkipped ? { loginSkipped: auth.facts.loginSkipped } : {}),
};
const warning = auth.arm === "oauth" ? undefined : auth.warning;
- if (warning) (params.warn ?? warnAdvisor)(`${params.spec}: ${warning}`);
+ const member = `${role}:${params.spec}`;
+ if (warning && !claudeAuthWarned.has(member)) {
+ claudeAuthWarned.add(member);
+ (params.warn ?? warnAdvisor)(`${params.spec}: ${warning}`);
+ }
if (auth.arm === null) {
return {
...stubOutcome(base, stubPaths.error, auth.reason, 0, []),