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 member reason

Jack Rudenko7b5fe89da424
diff --git a/ai-docs/architecture/advisor.md b/ai-docs/architecture/advisor.md
index 2e9c6638..92867130 100644
--- a/ai-docs/architecture/advisor.md
+++ b/ai-docs/architecture/advisor.md
@@ -617,9 +617,12 @@ 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 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 launch per Claude member AND reason 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`). Keyed by the warning text, which names only the reason and the key source,
+ never a value, so a later different reason (no bearer, then a skipped one; the request's
+ x-api-key, then ANTHROPIC_API_KEY) is printed too and the set stays bounded;
- 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 65e38d60..c72e6a4e 100644
--- a/packages/cli/src/handlers/native-handler-advisor.ts
+++ b/packages/cli/src/handlers/native-handler-advisor.ts
@@ -2111,11 +2111,15 @@ 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
+ * The (Claude member, warning) pairs, `"<role>:<spec>\n<warning>"`, 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 and reason, not once per advisor call. Keyed by the
+ * text too, so a later DIFFERENT reason for the same member (no bearer, then a
+ * skipped one; the request's x-api-key, then ANTHROPIC_API_KEY) is printed
+ * rather than hidden. The text names only a reason and a key source, never a
+ * value, so the set stays bounded. The per-call record still carries
* `loginSkipped` and the arm.
*/
const claudeAuthWarned = new Set<string>();
@@ -2153,9 +2157,9 @@ export async function runClaudeAdvisorCall(
...(auth.facts.loginSkipped ? { loginSkipped: auth.facts.loginSkipped } : {}),
};
const warning = auth.arm === "oauth" ? undefined : auth.warning;
- const member = `${role}:${params.spec}`;
- if (warning && !claudeAuthWarned.has(member)) {
- claudeAuthWarned.add(member);
+ const warnedKey = `${role}:${params.spec}\n${warning}`;
+ if (warning && !claudeAuthWarned.has(warnedKey)) {
+ claudeAuthWarned.add(warnedKey);
(params.warn ?? warnAdvisor)(`${params.spec}: ${warning}`);
}
if (auth.arm === null) {