Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(advisor): print a hop's billing label once in the notice
Jack Rudenko62be8abe3fd0
diff --git a/ai-docs/architecture/advisor.md b/ai-docs/architecture/advisor.mdindex feaf5c8a..c5c1dc38 100644--- a/ai-docs/architecture/advisor.md+++ b/ai-docs/architecture/advisor.md@@ -569,7 +569,9 @@ off the main status line by design.A routed member reads from its BUILT chain (`describeAdvisorPlan`,`handlers/advisor-route-plan.ts:618`): the first callable hop, each later hop a call can reach, arefusing hop the chain stops at, the subscription candidates routing skipped and why-(`skipped: … — no credential`), and hops that could not be built. A routed member's+(`skipped: … — no credential`), and hops that could not be built. Each hop is named by+`hopLabel`: its display name and billing word, the word printed once when the display name+already ends in it (`grok-4.7 -> Grok Build (subscription)`). A routed member's`subscription-not-served` / `subscription-credential-unreadable` warnings print under it as`note:` lines, because `route()`'s per-request notices never run for a panel call. A Claudemember on a launch claudish does not control reads `<spec> -> api.anthropic.com (metered, billeddiff --git a/packages/cli/src/handlers/advisor-route-plan.ts b/packages/cli/src/handlers/advisor-route-plan.tsindex 4ee1ab3b..e2c182d6 100644--- a/packages/cli/src/handlers/advisor-route-plan.ts+++ b/packages/cli/src/handlers/advisor-route-plan.ts@@ -314,6 +314,18 @@ export function billingWord(billing: AdvisorBilling): string {return billing === "subscription" ? "subscription" : "metered, billed per token";}+/**+ * A hop as a notice names it: its display name and its billing word, the word+ * printed once. Some display names already end in it (`Grok Build+ * (subscription)`), which read `Grok Build (subscription) (subscription)`.+ */+export function hopLabel(displayName: string, billing: AdvisorBilling): string {+ const suffix = `(${billingWord(billing)})`;+ return displayName.toLowerCase().endsWith(suffix.toLowerCase())+ ? displayName+ : `${displayName} ${suffix}`;+}+/** A `CandidateOutcome` as the notice's "skipped" phrase. */export const SKIPPED_PHRASE: Readonly<Record<Exclude<CandidateOutcome, "kept">, string>> = {"no-credential": "no credential",@@ -649,7 +661,7 @@ function laterHopParts(continue;}if (b.kind !== "built" && b.kind !== "built-pending") continue;- parts.push(`; then ${hop.displayName} (${billingWord(hop.billing)})`);+ parts.push(`; then ${hopLabel(hop.displayName, hop.billing)}`);if (hop.billing === "metered") metered = true;}return { parts, metered };@@ -670,10 +682,7 @@ export function describeAdvisorPlan(plan: AdvisorModelPlan, build?: AdvisorChainconst first = plan.hops[build.firstCallableHop];const later = laterHopParts(plan, build, build.firstCallableHop);- const parts = [- `${plan.spec} -> ${first.displayName} (${billingWord(first.billing)})`,- ...later.parts,- ];+ const parts = [`${plan.spec} -> ${hopLabel(first.displayName, first.billing)}`, ...later.parts];const laterMetered = later.metered;const skipped = plan.explanation.candidatesdiff --git a/packages/cli/src/handlers/native-handler-advisor.ts b/packages/cli/src/handlers/native-handler-advisor.tsindex 38b1f408..551194e6 100644--- a/packages/cli/src/handlers/native-handler-advisor.ts+++ b/packages/cli/src/handlers/native-handler-advisor.ts@@ -60,10 +60,10 @@ import {type AdvisorPanelResult,type AdvisorTurn,type ExtractedAdvice,- billingWord,buildAdvisorPanelPayload,describeAdvisorRefusal,extractAdvice,+ hopLabel,} from "./advisor-route-plan.js";import { extractProviderMessage, extractUpstreamStatus } from "./shared/anthropic-error.js";import { addSigningSecrets, credentialValuesFromRequest } from "./shared/call-context.js";@@ -2825,8 +2825,8 @@ function warnWhenServedUnlikePlan(if (servedUnlikePlan.get(key) === served) return;servedUnlikePlan.set(key, served);warn(- `${req.spec} was served by ${servedBy.displayName} (${billingWord(servedBy.billing)}), ` +- `not ${planned.displayName} (${billingWord(planned.billing)}) as the notice said; later ` ++ `${req.spec} was served by ${hopLabel(servedBy.displayName, servedBy.billing)}, ` ++ `not ${hopLabel(planned.displayName, planned.billing)} as the notice said; later ` +"calls start there (routing keeps the last hop that served)");}