Skip to content

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

fix(probe): say which auth problem a local server has, and keep walking on a denied model

Jack Rudenkoaac36ee54f20
diff --git a/packages/cli/src/providers/probe-live.ts b/packages/cli/src/providers/probe-live.ts
index d4f0faa0..ae467ef6 100644
--- a/packages/cli/src/providers/probe-live.ts
+++ b/packages/cli/src/providers/probe-live.ts
@@ -123,8 +123,20 @@ export interface ProbeLinkInput {
* for google is a Gemini 3 model, so every Gemini probe failed on its effort
* field. (Antigravity serves both families and needs no field at all — see
* EFFORT_OMITTED below.)
+ *
+ * `qwen-payg` validates the enum the same way Anthropic does, and says so:
+ * `400 InvalidParameter "Invalid value 'minimal' for output_config.effort.
+ * Supported values are: low, medium, high, xhigh, max."` (measured 2026-09-20 on
+ * dashscope-intl with qwen3.8-max-0902). Its sibling products do not: the Token
+ * Plan host accepts "minimal" on the same round of measurements, so this is one
+ * product's host, not a vendor-wide rule.
*/
-const MINIMAL_EFFORT_UNSUPPORTED = new Set(["native-anthropic", "anthropic", "google"]);
+const MINIMAL_EFFORT_UNSUPPORTED = new Set([
+ "native-anthropic",
+ "anthropic",
+ "google",
+ "qwen-payg",
+]);
/**
* Providers where NO effort value is valid for every model they serve, so the
@@ -390,6 +402,23 @@ export function classifyHttpError(status: number, body: string, latencyMs: numbe
errorMessage: extractErrorMessage(body) || `HTTP ${authStatus}`,
};
}
+ // Nor is it an auth failure when the provider accepted the credential and
+ // denied THIS MODEL. Alibaba's Model Studio answers
+ // `403 {"code":"Model.AccessDenied","message":"Model access denied."}` while
+ // the same key lists 169 models on the same host (measured 2026-09-19), so
+ // the credential is proven good by the provider itself. Reported as
+ // `auth-failed` it both blamed a working key and STOPPED Test All on the
+ // first candidate: the loop retries `error`, never `auth-failed`, so an
+ // account that may call some models but not the catalog's pick never got a
+ // second try. `error` keeps the failure without the false cause.
+ if (/model[^"]{0,24}access[ _-]?denied|access[ _-]?denied[^"]{0,24}model/i.test(body)) {
+ return {
+ state: "error",
+ latencyMs,
+ httpStatus: authStatus,
+ errorMessage: extractErrorMessage(body) || `HTTP ${authStatus}`,
+ };
+ }
// Nor is it an auth failure when the provider handed back a link to act on.
// Measured: Zen Go answers a model the account has not opted into with
// `403 RegionError … requires explicit opt in: <url>` — the credential is
diff --git a/packages/cli/src/providers/transport/local.ts b/packages/cli/src/providers/transport/local.ts
index 8f469a1a..9b4d0458 100644
--- a/packages/cli/src/providers/transport/local.ts
+++ b/packages/cli/src/providers/transport/local.ts
@@ -112,6 +112,7 @@ export class LocalTransport implements ProviderTransport {
key: `${this.config.name}:${this.config.baseUrl}`,
displayName: this.displayName,
exclude,
+ hasApiKey: Boolean(this.config.apiKey),
};
if (this.config.name === "ollama") {
return discoverViaOllama(this.config.baseUrl, {
diff --git a/packages/cli/src/providers/transport/probe-discovery.ts b/packages/cli/src/providers/transport/probe-discovery.ts
index 45633204..7e3698a2 100644
--- a/packages/cli/src/providers/transport/probe-discovery.ts
+++ b/packages/cli/src/providers/transport/probe-discovery.ts
@@ -309,7 +309,20 @@ function cacheSetRanked(key: string, ranked: string[]): void {
export async function discoverViaOpenAIModels(
endpoint: string,
headers: Record<string, string>,
- cacheKey: CacheKey & { displayName?: string; exclude?: ReadonlySet<string> }
+ cacheKey: CacheKey & {
+ displayName?: string;
+ exclude?: ReadonlySet<string>;
+ /**
+ * Whether a key is configured for this provider, for the 401/403 message.
+ *
+ * A local server that wants a key and a local server that rejects the key
+ * are different problems with different fixes, and "HTTP 401 from
+ * http://localhost:8000/v1/models" told the reader neither. Measured
+ * 2026-09-19: an oMLX server on vLLM's default port answers
+ * `401 {"error":{"message":"API key required"}}` to an unauthenticated list.
+ */
+ hasApiKey?: boolean;
+ }
): Promise<DiscoveryOutcome> {
const cached = cacheGet(cacheKey.key, cacheKey.exclude);
if (cached !== undefined) return cached;
@@ -331,7 +344,16 @@ export async function discoverViaOpenAIModels(
}
if (!response.ok) {
- const reason = `HTTP ${response.status} from ${endpoint}`;
+ const who = cacheKey.displayName ?? "this provider";
+ const authFailure =
+ response.status === 401 || response.status === 403
+ ? cacheKey.hasApiKey === false
+ ? `the server requires an API key and none is configured for ${who}`
+ : `the server rejected the configured API key for ${who}`
+ : "";
+ const reason = authFailure
+ ? `HTTP ${response.status} from ${endpoint} — ${authFailure}`
+ : `HTTP ${response.status} from ${endpoint}`;
log(`[probe-discovery${cacheKey.displayName ? `:${cacheKey.displayName}` : ""}] ${reason}`);
cacheSetFailure(cacheKey.key, reason);
return { model: null, reason };