Skip to content

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

fix: stop the probe tearing its own rows, and drop a hop no key can satisfy

Jack Rudenko406461c8b5d3
diff --git a/CLAUDE.md b/CLAUDE.md
index f623cc06..d139cfb8 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -110,6 +110,8 @@ negative case: if you are about to type one of those words, stop and use the lef
- `gk@` is the Grok SUBSCRIPTION; `grok@`/`xai@` is the metered `x-ai`. `moonshot-cn@` is a different service from `moonshot@`.
- A bare Claude name (`claude-opus-5`, `opus`, `internal`) must never reach `route()`: `native-anthropic` has no credential store, so the credential filter drops it and the chain degrades to OpenRouter. Check `nativeRouteFor()` (`providers/native-route.ts`) FIRST, as the proxy does — `preflight` and the TUI probe once didn't and told agents to drop their own subscription's models. Native routes also cannot be probed from outside a session (the handler forwards the inbound Claude Code header); report them as a third outcome, never as success or failure.
- A new `ClaudishProfileConfig` field MUST be added to `loadConfig`'s allowlist in `profile-config.ts`; otherwise it survives on disk until the first global save and is then dropped. Bit `onepasswordEnvironments`, then `keychain`.
+- Anything that renders a TUI to **stderr** must `setStderrQuiet(true)` for as long as it owns the screen, and release it in a `finally`. `logStderr` writes there too, so the two interleave inside one frame: the TUI repaints its own cells over part of the line and the surviving fragments read as a layout bug. `--probe` hit this — the tell was a stray `[c`, the head of `[claudish] `, left in a failed row. The message is not lost; `logStderr` always writes the debug log as well.
+- A `route binding` names one endpoint AND one credential silo. A provider that owns neither does not belong in `CATALOG_ROUTE_BINDINGS`, even when its name matches the `routeId`: since `providersForCatalogRoute` returns every provider bound to a route, a placeholder listed there becomes a route candidate and `--probe` prints a hop no key can ever satisfy. Do NOT fix that by filtering `reason: "virtual"` out of the gatherer — `native-anthropic` is virtual and genuinely routable through the native passthrough, so that filter takes `claude-*` away from anyone holding an `ANTHROPIC_API_KEY`.
## Commands
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts
index 1b73a2bd..54287a78 100644
--- a/packages/cli/src/cli.ts
+++ b/packages/cli/src/cli.ts
@@ -13,6 +13,7 @@ import { fileURLToPath } from "node:url";
import { EFFORT_LEVELS, isEffortLevel } from "./adapters/base-api-format.js";
import { ENV } from "./config.js";
import { buildLegacyHint, resolveDefaultProvider } from "./default-provider.js";
+import { setStderrQuiet } from "./logger.js";
import {
FIREBASE_SLUG_TO_PROVIDER_NAME,
type ModelDoc,
@@ -1974,6 +1975,23 @@ async function probeModelRouting(
};
const tui = await startProbeTui(initialState);
+ // THE TUI NOW OWNS stderr — nothing else may write there until it shuts down.
+ //
+ // `startProbeTui` renders to `process.stderr` on purpose, so `--json` keeps
+ // stdout clean. `logStderr` writes there too, and a probe that fails calls it
+ // once per failed hop from `composed-handler.ts`. Two writers, one terminal:
+ // the handler's line lands inside the TUI's frame, the TUI repaints its own
+ // cells over part of it, and what survives is a torn row. Measured on
+ // `--probe qwen3.8-max`, where Alibaba PAYG answers 403 — the stray `[c` left
+ // in the Alibaba PAYG row is the first two characters of `logStderr`'s
+ // `[claudish] ` prefix, and the rest of that line overwrote the Qwen row above.
+ //
+ // Suppressed, not redirected: `logStderr` always calls `log()` too, so every
+ // message still reaches the debug log (`--debug`), which is where a probe
+ // failure should be read from anyway. The row itself carries the classified
+ // reason via `ProbeResult.errorMessage`, so nothing the user needs is lost.
+ setStderrQuiet(true);
+
const addStep = (name: string, status: ProbeStepState["status"]): void => {
tui.store.setState((prev) => ({
...prev,
@@ -2242,6 +2260,9 @@ async function probeModelRouting(
}
}
await tui.shutdown();
+ // Hand stderr back AFTER the renderer is torn down, and in the `finally` so
+ // a throw mid-probe cannot leave the process permanently silent.
+ setStderrQuiet(false);
}
}
diff --git a/packages/cli/src/handlers/composed-handler.ts b/packages/cli/src/handlers/composed-handler.ts
index 9ebbe819..3c0be6e4 100644
--- a/packages/cli/src/handlers/composed-handler.ts
+++ b/packages/cli/src/handlers/composed-handler.ts
@@ -942,9 +942,19 @@ export class ComposedHandler implements ModelHandler {
const providerMsg = extractProviderMessage(parsedErrorBody ?? errorText);
// Richer stderr line: provider + status + hint + the real upstream message,
// so the cause is findable in scrollback even when Claude Code only shows
- // its own "API error · Retrying" banner. Bounded to one tidy line.
- const msgTail = providerMsg
- ? ` (${providerMsg.length > 200 ? `${providerMsg.slice(0, 200)}…` : providerMsg})`
+ // its own "API error · Retrying" banner.
+ //
+ // "One tidy line" used to be bounded by LENGTH alone, which is a different
+ // promise: `extractProviderMessage` returns a non-JSON body verbatim, and a
+ // provider may answer an error as an SSE frame rather than a document —
+ // Alibaba Model Studio answers a denied model with `event:error\ndata:{…}`.
+ // 200 characters of that is still three lines, and three lines written into
+ // a terminal a TUI is painting tears the frame. Collapsing whitespace FIRST
+ // is what makes the sentence true; the slice then bounds what is already
+ // one line.
+ const oneLineMsg = providerMsg.replace(/\s+/g, " ").trim();
+ const msgTail = oneLineMsg
+ ? ` (${oneLineMsg.length > 200 ? `${oneLineMsg.slice(0, 200)}…` : oneLineMsg})`
: "";
logStderr(
`Error [${this.provider.displayName}]: HTTP ${response.status}. ${hint}${msgTail}`
diff --git a/packages/cli/src/handlers/shared/anthropic-error.ts b/packages/cli/src/handlers/shared/anthropic-error.ts
index c7d1e7e9..99baafc3 100644
--- a/packages/cli/src/handlers/shared/anthropic-error.ts
+++ b/packages/cli/src/handlers/shared/anthropic-error.ts
@@ -147,6 +147,32 @@ export function extractUpstreamStatus(body: string): number | undefined {
}
}
+/**
+ * The concatenated `data:` payload of an SSE frame, or undefined for anything
+ * else. Exported because the probe needs the same reading.
+ *
+ * A provider may answer an ERROR as a stream rather than a document — the
+ * request asked for `stream: true`, so some providers answer in kind. Alibaba
+ * Model Studio does exactly this for a denied model:
+ *
+ * event:error
+ * data:{"code":"AccessDenied","message":"Model access denied.","request_id":"…"}
+ *
+ * The whole frame is not JSON, so every JSON ladder below it fails and the frame
+ * survives verbatim into a user-facing sentence — three lines of wire protocol
+ * where "Model access denied." belonged. Multiple `data:` lines concatenate,
+ * per the SSE specification.
+ */
+export function sseDataPayload(body: string): string | undefined {
+ if (!/(^|\n)\s*(event|data):/.test(body)) return undefined;
+ const data = body
+ .split(/\r?\n/)
+ .filter((line) => line.startsWith("data:"))
+ .map((line) => line.slice("data:".length).trim())
+ .join("");
+ return data.length > 0 ? data : undefined;
+}
+
/**
* Pull the most useful human-readable message out of an arbitrary provider
* error body (already JSON-parsed, or a raw string). Mirrors the extraction
@@ -154,7 +180,22 @@ export function extractUpstreamStatus(body: string): number | undefined {
*/
export function extractProviderMessage(body: any): string {
if (body == null) return "";
- if (typeof body === "string") return body;
+ if (typeof body === "string") {
+ // A streamed error is still a document once the frame is opened. Only the
+ // payload is re-entered, so a frame that carries no recognisable message
+ // falls back to the frame itself rather than to nothing.
+ const payload = sseDataPayload(body);
+ if (payload) {
+ try {
+ const inner = extractProviderMessage(JSON.parse(payload));
+ if (inner) return inner;
+ } catch {
+ return payload;
+ }
+ return payload;
+ }
+ return body;
+ }
const candidates = [
body?.error?.message,
body?.message,
diff --git a/packages/cli/src/probe/probe-tui-app.tsx b/packages/cli/src/probe/probe-tui-app.tsx
index 41e2fdba..585c213f 100644
--- a/packages/cli/src/probe/probe-tui-app.tsx
+++ b/packages/cli/src/probe/probe-tui-app.tsx
@@ -183,6 +183,8 @@ const TIMELINE_BAR_FULL = 24; // B
const TIMELINE_BAR_NARROW = 12; // B when <80 cols
const TOK_BAR_FULL = 14; // T
const TOTAL_COL = 7; // right-aligned "14.34s"
+/** The live row's leading `" MM:SS "` — 4 indent + 5 clock + 2 gap. */
+const ELAPSED_COL = 11;
// Each stage number is right-aligned to STAGE_NUM_W so the inner net/srv/str
// columns line up across rows. W=6 fits the realistic worst case "21.05s".
const STAGE_NUM_W = 6;
@@ -202,6 +204,16 @@ interface ProbeLayout {
showBreakdown: boolean;
/** Whether to fall back to today's single latency pill (<60 cols). */
pillFallback: boolean;
+ /**
+ * The terminal width this layout was derived from.
+ *
+ * Carried because the pill fallback renders a failure reason with NO column to
+ * clip against — it has no timeline slot, which is where every other layout
+ * puts the reason and where the clipping happens. Without a width, a long
+ * provider message wrapped across as many rows as it needed, over the rows
+ * already drawn.
+ */
+ width: number;
}
/**
@@ -214,7 +226,7 @@ interface ProbeLayout {
*/
function deriveLayout(width: number): ProbeLayout {
if (width < 60) {
- return { barWidth: 0, tokWidth: 0, showBreakdown: false, pillFallback: true };
+ return { barWidth: 0, tokWidth: 0, showBreakdown: false, pillFallback: true, width };
}
if (width < 80) {
return {
@@ -222,6 +234,7 @@ function deriveLayout(width: number): ProbeLayout {
tokWidth: 0,
showBreakdown: false,
pillFallback: false,
+ width,
};
}
if (width < 100) {
@@ -230,6 +243,7 @@ function deriveLayout(width: number): ProbeLayout {
tokWidth: 0,
showBreakdown: true,
pillFallback: false,
+ width,
};
}
return {
@@ -237,6 +251,7 @@ function deriveLayout(width: number): ProbeLayout {
tokWidth: TOK_BAR_FULL,
showBreakdown: true,
pillFallback: false,
+ width,
};
}
@@ -293,9 +308,37 @@ function padEndSafe(s: string, n: number): string {
return s + " ".repeat(n - s.length);
}
+/**
+ * Clip a failure reason to what is left of the terminal, ending in an ellipsis
+ * so a cut reads as a cut. Never pads: the reason is the last thing on its row.
+ */
+function clipReason(s: string, width: number): string {
+ const room = Math.max(8, width - 2);
+ return s.length <= room ? s : `${s.slice(0, room - 1)}…`;
+}
+
+/**
+ * Make provider text safe to paint on ONE row: no escape sequences, no control
+ * characters, no line breaks.
+ *
+ * The newline half is not cosmetic. Every caller is rendering an error message
+ * into a fixed-width slot, and `padEndSafe` clips by CHARACTER COUNT — so a `\n`
+ * that lands inside the clip survives it, ends the row where the terminal says
+ * it ends rather than where the layout says, and pushes the remaining columns
+ * onto the line below, over whatever is already there. `probe-live.ts` now
+ * flattens its messages at the source; this is the second wall, because the
+ * string also reaches here from provider text that never passed through there.
+ */
function stripAnsi(text: string): string {
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences require control chars
- return text.replace(/\x1b\[[0-9;]*[A-Za-z]/g, "");
+ return (
+ text
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequences require control chars
+ .replace(/\x1b\[[0-9;]*[A-Za-z]/g, "")
+ // Whitespace RUNS, not just newlines: a collapsed frame otherwise leaves a
+ // gap the width of its indentation in the middle of the sentence.
+ .replace(/\s+/g, " ")
+ .trim()
+ );
}
// ── Banner ─────────────────────────────────────────────────────────
@@ -443,20 +486,45 @@ function ProgressBar({
return (
<text>
{prefix}
- {renderNonLiveStatus(link, /* hasSlot */ false)}
+ {renderNonLiveStatus(link, /* hasSlot */ false, layout.width)}
+ </text>
+ );
+ }
+
+ // \u2014\u2014 FAILED row: the reason gets the WHOLE rest of the line \u2014\u2014
+ //
+ // A failed row draws no timeline bar, no breakdown and no tok/s bar, so every
+ // column after the provider name is dead space. It used to be spent on
+ // alignment anyway: the reason was padded into the `barWidth` slot (24 cols)
+ // so a trailing \u2717 could line up with the live rows above. At 24 columns
+ // "\u2717 error \u00b7 403 \u00b7 1151ms \u2014 Model access denied." clips to
+ // "\u2717 error \u00b7 403 \u00b7 1151ms \u2014", which ends on a dash promising a sentence that
+ // was thrown away \u2014 the one line on the row the reader needed.
+ //
+ // So the marker goes (the reason already starts with \u2717; a second one said
+ // nothing) and the reason runs to the edge of the terminal.
+ if (link.status === "failed") {
+ const used = ELAPSED_COL + maxNameLen + 2;
+ return (
+ <text>
+ {prefix}
+ <span fg={C.red}>
+ {clipReason(`\u2717 ${stripAnsi(link.error || "failed")}`, layout.width - used)}
+ </span>
</text>
);
}
- // \u2014\u2014 Non-live rows: blank both bars to a track, keep alignment \u2014\u2014
- // The TIMELINE slot carries the failed reason, so the status is a bare \u2717.
+ // \u2014\u2014 Other non-live rows (probing / waiting): blank both bars to a track \u2014\u2014
+ // These DO keep the aligned slot: the animated bar is positional feedback, and
+ // it only reads as progress when it sits where the finished bars will sit.
if (link.status !== "live" || !link.timing) {
return (
<text>
{prefix}
{renderTimelineSlot(link, animFrame, layout.barWidth)}
<span fg={C.dim}>{" "}</span>
- {renderNonLiveStatus(link, /* hasSlot */ true)}
+ {renderNonLiveStatus(link, /* hasSlot */ true, layout.width)}
</text>
);
}
@@ -559,10 +627,11 @@ function renderTimelineSlot(link: ProbeLinkState, animFrame: number, barWidth: n
* `hasSlot` = true when a TIMELINE slot is also rendered for this row (the
* normal layout): in that case the failed REASON already lives in the slot, so
* the status is a bare red `\u2717` marker \u2014 no duplicate error text. When `hasSlot`
- * is false (the <60-col pill fallback, no slot), the status carries the full
- * reason itself.
+ * is false (the <60-col pill fallback, no slot), the status carries the reason
+ * itself \u2014 CLIPPED to the terminal, because there is no column to clip it to.
+ * Unclipped, a 400-character provider message wrapped across every row below it.
*/
-function renderNonLiveStatus(link: ProbeLinkState, hasSlot: boolean) {
+function renderNonLiveStatus(link: ProbeLinkState, hasSlot: boolean, width: number) {
switch (link.status) {
case "probing": {
const elapsedMs = link.startTime ? Date.now() - link.startTime : 0;
@@ -572,7 +641,7 @@ function renderNonLiveStatus(link: ProbeLinkState, hasSlot: boolean) {
return hasSlot ? (
<span fg={C.red}>{"\u2717"}</span>
) : (
- <span fg={C.red}>{`\u2717 ${stripAnsi(link.error || "failed")}`}</span>
+ <span fg={C.red}>{clipReason(`\u2717 ${stripAnsi(link.error || "failed")}`, width)}</span>
);
default:
return <span fg={C.dim}>{"\u23F3 waiting\u2026"}</span>;
@@ -799,12 +868,18 @@ function DetailLinkRow({
);
if (!isLive || !probe?.timing) {
- // Failed / missing — keep the provider column aligned, then ✗ + dim reason.
+ // Failed / missing — keep the provider column aligned, then ✗ + dim reason,
+ // CLIPPED to what is left of the terminal. `describeProbeState` returns the
+ // provider's own sentence and a provider is free to make it 400 characters
+ // long; unclipped it wrapped over the rows below instead of ending.
+ const used = 2 + 1 + 1 + provW + 2 + 3;
return (
<text>
{lead}
<span fg={C.red}>{"✗ "}</span>
- <span fg={C.red}>{shortFailureReason(probe, link.hasCredentials)}</span>
+ <span fg={C.red}>
+ {clipReason(shortFailureReason(probe, link.hasCredentials), layout.width - used)}
+ </span>
</text>
);
}
diff --git a/packages/cli/src/providers/catalog-route-bindings.ts b/packages/cli/src/providers/catalog-route-bindings.ts
index 7e6216ef..851c256a 100644
--- a/packages/cli/src/providers/catalog-route-bindings.ts
+++ b/packages/cli/src/providers/catalog-route-bindings.ts
@@ -37,7 +37,23 @@ export const CATALOG_ROUTE_BINDINGS: Readonly<Record<string, CatalogRouteBinding
"qwen-coding": { routeId: "qwen", routeProfileId: "modelstudio-coding-plan" },
"qwen-token-plan": { routeId: "qwen", routeProfileId: "qwencloud-token-plan" },
"qwen-payg": { routeId: "qwen", routeProfileId: "dashscope-direct" },
- qwen: { routeId: "qwen", routeProfileId: "dashscope-direct" },
+ // `qwen` is NOT bound, deliberately. A binding names one endpoint and one
+ // credential silo (see this file's header); `qwen` is a steering placeholder
+ // that owns neither — no baseUrl, no apiPath, no apiKeyEnvVar — and
+ // `qwen-payg` is what actually calls dashscope. It was listed here while
+ // `providerForCatalogRoute` returned only the FIRST provider per route, which
+ // hid it behind `qwen-payg`. v10.0.0's `providersForCatalogRoute` returns all
+ // of them (the z-ai/glm key-silo fix) and the placeholder surfaced: a
+ // `Qwen ✗ key missing` hop in `--probe qwen3.8-max`, sending the reader after
+ // a key no environment variable can hold. `route()` never yielded it, so the
+ // damage was confined to the display.
+ //
+ // Not fixed by filtering placeholders out of the gatherer: `native-anthropic`
+ // is a placeholder too, by the same `reason: "virtual"` marker, and it IS
+ // routable — the proxy's native passthrough serves it, so a filter on that
+ // marker took `claude-*` away from anyone holding an ANTHROPIC_API_KEY.
+ // Measured: two routing tests went red. The binding table is where the wrong
+ // claim lived, so it is where the correction belongs.
"opencode-zen-go": { routeId: "opencode", routeProfileId: "go-subscription" },
"opencode-zen": { routeId: "opencode", routeProfileId: "zen" },
zen: { routeId: "opencode", routeProfileId: "zen" },
diff --git a/packages/cli/src/providers/probe-live.ts b/packages/cli/src/providers/probe-live.ts
index 98b0abff..3a0687fa 100644
--- a/packages/cli/src/providers/probe-live.ts
+++ b/packages/cli/src/providers/probe-live.ts
@@ -12,7 +12,7 @@
* not a silent failover to something else.
*/
-import { extractUpstreamStatus } from "../handlers/shared/anthropic-error.js";
+import { extractUpstreamStatus, sseDataPayload } from "../handlers/shared/anthropic-error.js";
import {
hasActionableLink,
hasModelUnsupportedWording,
@@ -577,19 +577,45 @@ function truncateKeepingLink(text: string, max = 400): string {
return `${prose}... ${url}`;
}
-function extractErrorMessage(body: string): string | undefined {
- if (!body) return undefined;
+/**
+ * ONE LINE, always. Every consumer of a probe error message renders it on a
+ * single row, and a newline is the one character none of them can survive: the
+ * TUI clips by character count, so a `\n` inside the clip ends the row early and
+ * everything after it paints over the row below. `truncateKeepingLink` bounds
+ * LENGTH, which is a different promise and was mistaken for this one.
+ */
+function oneLine(text: string): string {
+ return text.replace(/\s+/g, " ").trim();
+}
+
+/** The message a JSON error document carries, under any of the shapes seen. */
+function messageFromJson(text: string): string | undefined {
try {
- const parsed = JSON.parse(body);
+ const parsed = JSON.parse(text);
const msg =
parsed?.error?.message || parsed?.error?.error?.message || parsed?.message || parsed?.detail;
- if (typeof msg === "string" && msg.length > 0) {
- return truncateKeepingLink(msg);
- }
+ return typeof msg === "string" && msg.length > 0 ? msg : undefined;
} catch {
- // not JSON, fall through
+ return undefined;
}
- const trimmed = body.trim();
+}
+
+function extractErrorMessage(body: string): string | undefined {
+ if (!body) return undefined;
+
+ const direct = messageFromJson(body);
+ if (direct) return truncateKeepingLink(oneLine(direct));
+
+ // Not a JSON document. It may still be an SSE frame carrying one.
+ const payload = sseDataPayload(body);
+ if (payload) {
+ const streamed = messageFromJson(payload);
+ if (streamed) return truncateKeepingLink(oneLine(streamed));
+ // A `data:` payload that is not JSON is still better than the whole frame.
+ return truncateKeepingLink(oneLine(payload));
+ }
+
+ const trimmed = oneLine(body);
if (!trimmed) return undefined;
return truncateKeepingLink(trimmed);
}
@@ -868,7 +894,29 @@ function isContentEvent(parsed: any, eventType: string): boolean {
* a bucket, not a diagnosis; the body is the diagnosis.
*/
function withDetail(base: string, message?: string): string {
- return message ? `${base} — ${message}` : base;
+ return message ? `${base} — ${stripRedundantHead(message)}` : base;
+}
+
+/**
+ * Drop the `"<Provider> error (HTTP <status>): "` head claudish put on its own
+ * message, because `base` has just said both of those things.
+ *
+ * The head is composed by `composeErrorMessage` for the proxy's stderr line and
+ * for the body it returns to Claude Code, where naming the provider and the code
+ * is the whole point — nothing else on that line does. A probe row is the
+ * opposite situation: the provider is the row's own left column and the status is
+ * the first thing `base` prints, so the head repeats 30 columns of what the
+ * reader can already see, and 30 columns is what the row has left for the part
+ * that says what to DO. Measured on `--probe qwen3.8-max` at 130 columns: the
+ * summary row ended at "…accepted the credential but c", cutting the sentence
+ * exactly where it turns actionable.
+ *
+ * Anchored to the full composed shape, not to " error" or the provider name: a
+ * provider's own prose has to match `(HTTP <3 digits>): ` to be touched, and no
+ * upstream message observed does.
+ */
+function stripRedundantHead(message: string): string {
+ return message.replace(/^.{1,40}? error \(HTTP \d{3}\): /, "");
}
export function describeProbeState(result: ProbeResult): string {
diff --git a/packages/cli/src/providers/provider-definitions.test.ts b/packages/cli/src/providers/provider-definitions.test.ts
index ed7e0d49..2222757b 100644
--- a/packages/cli/src/providers/provider-definitions.test.ts
+++ b/packages/cli/src/providers/provider-definitions.test.ts
@@ -17,6 +17,7 @@ import {
} from "../handlers/shared/remote-provider-types.js";
import { setConfigFileOverride } from "../profile-config.js";
import { API_KEY_MAP } from "./api-key-map.js";
+import { CATALOG_ROUTE_BINDINGS } from "./catalog-route-bindings.js";
import {
BUILTIN_PROVIDERS,
getApiKeyEnvVars,
@@ -199,10 +200,42 @@ describe("BUILTIN_PROVIDERS structural integrity", () => {
"native-anthropic",
"ollama",
"openrouter",
+ "qwen", // Steering placeholder; qwen-payg serves dashscope.
"vllm",
]);
});
+ test("catalog bindings exclude the qwen steering placeholder but retain native passthrough", () => {
+ let resolvedBuiltinBindings = 0;
+
+ for (const providerName of Object.keys(CATALOG_ROUTE_BINDINGS)) {
+ const provider = getProviderByName(providerName);
+ if (!provider) continue;
+
+ resolvedBuiltinBindings += 1;
+ expect(provider.tier).toBeDefined();
+ }
+
+ // The loop must exercise real bindings, not pass vacuously on an empty or
+ // wholly unresolved table.
+ expect(resolvedBuiltinBindings).toBeGreaterThan(0);
+
+ // qwen only steers bare names; qwen-payg owns dashscope and its credentials.
+ expect(CATALOG_ROUTE_BINDINGS.qwen).toBeUndefined();
+ expect(CATALOG_ROUTE_BINDINGS["qwen-payg"]).toEqual({
+ routeId: "qwen",
+ routeProfileId: "dashscope-direct",
+ });
+
+ // A no-handler marker is not itself grounds for removing a binding: this
+ // route is executed by the proxy's native passthrough.
+ expect(getProviderByName("native-anthropic")?.tier).toBe("subscription");
+ expect(CATALOG_ROUTE_BINDINGS["native-anthropic"]).toEqual({
+ routeId: "anthropic",
+ routeProfileId: "claude-code-subscription",
+ });
+ });
+
test("recent subscription providers have real handler factories", () => {
for (const providerName of ["grok-subscription", "antigravity"]) {
const provider = getProviderByName(providerName);
diff --git a/packages/cli/src/providers/provider-definitions.ts b/packages/cli/src/providers/provider-definitions.ts
index 2dc1e3ac..6c06d4ed 100644
--- a/packages/cli/src/providers/provider-definitions.ts
+++ b/packages/cli/src/providers/provider-definitions.ts
@@ -1475,12 +1475,24 @@ export const BUILTIN_PROVIDERS: TieredProviderDefinition[] = [
// ── Qwen (auto-routed, no direct API) ──────────────────────────────
{
- createHandler: openaiHandler,
- // The vendor's own namespace, so `native` — but unreachable as a gathered
- // candidate either way: it shares `qwen/dashscope-direct` with `qwen-payg`,
- // which `providerForCatalogRoute` returns first (earlier key), and it holds
- // no credential of its own for the credential filter to find. This entry
- // exists so a bare `qwen*` name has a provider to be steered FROM.
+ // VIRTUAL, and it must say so: no baseUrl, no apiPath, no apiKeyEnvVar.
+ // The entry exists so a bare `qwen*` name has a provider to be steered
+ // FROM; `qwen-payg` is what actually calls dashscope.
+ //
+ // It used to carry `openaiHandler` and a comment arguing it was unreachable
+ // anyway, because `providerForCatalogRoute` returned only the FIRST provider
+ // bound to `qwen/dashscope-direct` and `qwen-payg` is the earlier key. v10.0.0
+ // replaced that with `providersForCatalogRoute`, which returns ALL of them —
+ // the z-ai/glm key-silo fix — and deleted the premise. This became a gathered
+ // candidate, so `--probe qwen3.8-max` printed a `Qwen ✗ key missing` hop and
+ // sent the reader looking for a key that no environment variable can hold.
+ // `route()` never yielded it (the credential filter drops it), so the damage
+ // was confined to the display; `reason: "virtual"` is what keeps it that way.
+ createHandler: noHandler(
+ "virtual",
+ "No baseUrl. Exists only so nativeModelPatterns can steer a bare qwen* name; qwen-payg serves dashscope."
+ ),
+ // The vendor's own namespace, so `native`.
tier: "native",
name: "qwen",
displayName: "Qwen",
diff --git a/packages/cli/src/providers/provider-routing.test.ts b/packages/cli/src/providers/provider-routing.test.ts
index c61b39be..658fecf2 100644
--- a/packages/cli/src/providers/provider-routing.test.ts
+++ b/packages/cli/src/providers/provider-routing.test.ts
@@ -215,6 +215,7 @@ describe("Provider handlers", () => {
"lmstudio",
"vllm",
"mlx",
+ "qwen", // Steering placeholder; qwen-payg serves dashscope.
"native-anthropic",
];
const handlerlessProviders = BUILTIN_PROVIDERS.filter(
diff --git a/packages/cli/src/providers/route-candidates.test.ts b/packages/cli/src/providers/route-candidates.test.ts
index efb44b83..f702c11d 100644
--- a/packages/cli/src/providers/route-candidates.test.ts
+++ b/packages/cli/src/providers/route-candidates.test.ts
@@ -346,6 +346,15 @@ describe("namespace claims and availability", () => {
});
describe("fallback placement and no-catalog behavior", () => {
+ test("does not display the qwen steering placeholder as a dashscope hop", () => {
+ const providers = buildCatalogChain("qwen3.8-max", "", cachePath).routes.map(
+ ({ provider }) => provider
+ );
+
+ expect(providers).toContain("qwen-payg");
+ expect(providers).not.toContain("qwen");
+ });
+
test("appends the fallback last and does not duplicate an existing candidate", () => {
const missingModel = buildCatalogChain("swe-1.7", undefined, cachePath);
expect(missingModel.routes.map(({ provider }) => provider)).toEqual(["devin", "openrouter"]);