Skip to content

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

test: give the route, grok-effort and vertex tests the catalog they read

Jack Rudenkode27ab124141
diff --git a/packages/cli/src/adapters/effort-mapping.test.ts b/packages/cli/src/adapters/effort-mapping.test.ts
index 4c5e0d7f..7e408a35 100644
--- a/packages/cli/src/adapters/effort-mapping.test.ts
+++ b/packages/cli/src/adapters/effort-mapping.test.ts
@@ -44,12 +44,29 @@ function seedDefaultCatalog(entries: DiskCacheV3["entries"]): () => void {
);
return () => rmSync(cachePath, { force: true });
}
+/**
+ * Dialects that read the seeded catalog at `cachePath`. The base lookups read the real
+ * ~/.claudish catalog, so a test that seeds and then uses a plain dialect is reading whatever
+ * that machine last fetched: it passes on a developer's machine and fails on a fresh runner.
+ */
+const seeded = {
+ capability: (modelId: string) => lookupModelReasoning(modelId, cachePath),
+ status: (modelId: string) => lookupModelReasoningStatus(modelId, cachePath),
+};
class CatalogDeepSeek extends DeepSeekModelDialect {
protected override lookupReasoningCapability() {
- return lookupModelReasoning(this.getModelId(), cachePath);
+ return seeded.capability(this.getModelId());
+ }
+ protected override lookupReasoningStatus() {
+ return seeded.status(this.getModelId());
+ }
+}
+class CatalogGrok extends GrokModelDialect {
+ protected override lookupReasoningCapability() {
+ return seeded.capability(this.getModelId());
}
protected override lookupReasoningStatus() {
- return lookupModelReasoningStatus(this.getModelId(), cachePath);
+ return seeded.status(this.getModelId());
}
}
@@ -167,7 +184,7 @@ describe("Gemini thinking config", () => {
// ─── Part 2D: Grok ────────────────────────────────────────────────────────
function grokEffort(modelId: string, req: any): string | undefined {
- const fmt = new GrokModelDialect(modelId);
+ const fmt = new CatalogGrok(modelId);
(fmt as any).modelId = modelId;
const out = (fmt as any).prepareRequest({}, req);
return out.reasoning_effort;
diff --git a/packages/cli/src/adapters/grok-effort-support.ts b/packages/cli/src/adapters/grok-effort-support.ts
index 6a1029e6..0fbf3680 100644
Binary files a/packages/cli/src/adapters/grok-effort-support.ts and b/packages/cli/src/adapters/grok-effort-support.ts differ
diff --git a/packages/cli/src/adapters/grok-model-dialect.ts b/packages/cli/src/adapters/grok-model-dialect.ts
index 034a8f4f..6f879950 100644
--- a/packages/cli/src/adapters/grok-model-dialect.ts
+++ b/packages/cli/src/adapters/grok-model-dialect.ts
@@ -21,7 +21,6 @@ import {
import {
acceptsReasoningEffort,
acceptsReasoningEffortValue,
- catalogReasoningFor,
fallbackReasoningEffortValue,
isReasoningEffortRejection,
rejectedReasoningEffortValue,
@@ -149,7 +148,7 @@ export class GrokModelDialect extends BaseAPIFormat {
// CATALOG FIRST — same rule OpenAIAPIFormat follows, and for the same
// measured reason: a name rule is wrong in both directions.
- const reasoning = catalogReasoningFor(this.modelId);
+ const reasoning = this.lookupReasoningCapability();
const clamped = reasoning ? this.clampToAdvertisedEffort(effort, reasoning) : undefined;
if (clamped) {
value = clamped;
diff --git a/packages/cli/src/providers/routing-rules.test.ts b/packages/cli/src/providers/routing-rules.test.ts
index 2d03b0f6..36bd483b 100644
--- a/packages/cli/src/providers/routing-rules.test.ts
+++ b/packages/cli/src/providers/routing-rules.test.ts
@@ -661,6 +661,25 @@ const ENV_KEYS_TO_CLEAR = [
const savedEnv: Record<string, string | undefined> = {};
+/**
+ * Route `modelId` against a catalog that publishes it through `providers` only. Without a
+ * catalog path, route() reads the real ~/.claudish catalog: whatever that machine last
+ * fetched, and nothing at all on a fresh runner.
+ */
+async function routeOnCatalog(modelId: string, providers: string[]): Promise<RoutePlan> {
+ const { path, cleanup } = makeTempCatalog(
+ { modelId, externalId: modelId },
+ undefined,
+ {},
+ providers
+ );
+ try {
+ return await route(modelId, {}, undefined, path);
+ } finally {
+ cleanup();
+ }
+}
+
describe("route()", () => {
let previousKeychainGuard: string | undefined;
@@ -705,7 +724,7 @@ describe("route()", () => {
test("claude-opus-4-7 with ANTHROPIC_API_KEY → primary native-anthropic", async () => {
process.env.ANTHROPIC_API_KEY = "sk-ant-test";
- const plan = await route("claude-opus-4-7", {});
+ const plan = await routeOnCatalog("claude-opus-4-7", ["native-anthropic", "openrouter"]);
expect(plan.kind).toBe("ok");
if (plan.kind !== "ok") return;
expect(plan.primary.provider).toBe("native-anthropic");
@@ -729,14 +748,14 @@ describe("route()", () => {
test("claude-opus-4-7 with only OPENROUTER_API_KEY → primary openrouter", async () => {
process.env.OPENROUTER_API_KEY = "or-test";
- const plan = await route("claude-opus-4-7", {});
+ const plan = await routeOnCatalog("claude-opus-4-7", ["native-anthropic", "openrouter"]);
expect(plan.kind).toBe("ok");
if (plan.kind !== "ok") return;
expect(plan.primary.provider).toBe("openrouter");
});
test("claude-opus-4-7 with no credentials → no-route, hint mentions both providers", async () => {
- const plan = await route("claude-opus-4-7", {});
+ const plan = await routeOnCatalog("claude-opus-4-7", ["native-anthropic", "openrouter"]);
expect(plan.kind).toBe("no-route");
if (plan.kind !== "no-route") return;
expect(plan.hint).toBeDefined();
@@ -781,7 +800,7 @@ describe("route()", () => {
if (existsSync(codexOauth)) return;
process.env.OPENAI_API_KEY = "sk-openai-test";
- const plan = await route("gpt-5", {});
+ const plan = await routeOnCatalog("gpt-5", ["openai-codex", "openai"]);
expect(plan.kind).toBe("ok");
if (plan.kind !== "ok") return;
expect(plan.primary.provider).toBe("openai");
diff --git a/packages/cli/src/providers/transport/vertex-discovery.test.ts b/packages/cli/src/providers/transport/vertex-discovery.test.ts
index 8537a2e0..c38b2487 100644
--- a/packages/cli/src/providers/transport/vertex-discovery.test.ts
+++ b/packages/cli/src/providers/transport/vertex-discovery.test.ts
@@ -1,6 +1,12 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterAll, afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
import { credentials } from "../../auth/credentials/authority.js";
import { resetVertexProjectDiscovery } from "../../auth/vertex-auth.js";
+import { type DiskCacheV3, writeAllModelsCache } from "../all-models-cache.js";
+import { _resetCatalogClient, _setCatalogEntriesForTest } from "../catalog-client.js";
+import { _setChatCapabilityCachePathForTest } from "./probe-discovery.js";
import { _clearVertexDiscoveryCache, discoverVertexProbeModel } from "./vertex-discovery.js";
import { parseVertexModel } from "./vertex-oauth.js";
@@ -24,6 +30,42 @@ const listedModels = [
},
];
+/**
+ * The catalog rows discovery reads: chat capability (from the output modality) and the release
+ * date that ranks 3.8 above 2.5. Seeded here, because without them discovery reads the real
+ * ~/.claudish catalog — present on a developer's machine, absent on a fresh runner.
+ */
+const catalogEntries = [
+ {
+ modelId: "gemini-3.8-flash",
+ aliases: [],
+ inputModalities: ["text"],
+ outputModalities: ["text"],
+ releaseDate: "2026-08-01",
+ },
+ {
+ modelId: "gemini-2.5-flash",
+ aliases: [],
+ inputModalities: ["text"],
+ outputModalities: ["text"],
+ releaseDate: "2025-06-17",
+ },
+] as DiskCacheV3["entries"];
+const catalogDir = mkdtempSync(join(tmpdir(), "vertex-discovery-catalog-"));
+const catalogPath = join(catalogDir, "catalog.json");
+writeAllModelsCache(
+ {
+ version: 3,
+ catalogGenerationId: "test-generation",
+ lastUpdated: new Date().toISOString(),
+ entries: catalogEntries,
+ models: [],
+ plans: [],
+ },
+ catalogPath
+);
+afterAll(() => rmSync(catalogDir, { recursive: true, force: true }));
+
function installHttpFixture(statuses: Record<string, number>): string[] {
const requests: string[] = [];
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
@@ -54,9 +96,13 @@ describe.serial("Vertex discovery confirmation", () => {
credentials.getRequestAuth = async () => ({
headers: { Authorization: "Bearer offline-vertex-test-token" },
});
+ _setCatalogEntriesForTest(catalogEntries);
+ _setChatCapabilityCachePathForTest(catalogPath);
});
afterEach(() => {
+ _setChatCapabilityCachePathForTest(undefined);
+ _resetCatalogClient();
globalThis.fetch = originalFetch;
credentials.getRequestAuth = originalGetRequestAuth;
if (originalProject === undefined) delete process.env.VERTEX_PROJECT;