Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ function routeModelInternal(
throw new Error(`No provider configured for model: ${modelId}`);
}
if (hasOwnProvider(config.providers, provName)) {
const conflictingDefault = activeProviderEntries(config)
.find(([candidateName, candidate]) => candidateName !== provName && candidate.defaultModel === modelId);
if (conflictingDefault) {
throw new Error(
`Ambiguous model selector ${modelId}: it is both the default model for provider `
+ `${conflictingDefault[0]} and a ${provName} provider namespace. Use an encoded `
+ `${conflictingDefault[0]}/<model> selector to choose the default-model provider explicitly.`,
);
}
const prov = config.providers[provName];
if (prov.disabled === true) throw new Error(`Provider is disabled: ${provName}`);
const known = knownModelIdsForProvider(provName, prov);
Expand Down
22 changes: 22 additions & 0 deletions tests/commandcode-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,28 @@ describe("Command Code provider", () => {
expect(body.parallel_tool_calls).toBe(true);
});

test("rejects an ambiguous native default instead of routing it through DeepSeek", () => {
const config = commandcodeConfig({
defaultModel: "deepseek/deepseek-v4-flash",
models: ["deepseek/deepseek-v4-flash"],
});
config.providers.deepseek = {
adapter: "openai-chat",
baseUrl: "https://api.deepseek.com",
authMode: "key",
apiKey: "deepseek-test-key",
defaultModel: "deepseek-v4-flash",
models: ["deepseek-v4-flash"],
};

expect(() => routeModel(config, "deepseek/deepseek-v4-flash"))
.toThrow("Ambiguous model selector deepseek/deepseek-v4-flash");
expect(routeModel(config, "commandcode/deepseek-deepseek-v4-flash")).toMatchObject({
providerName: "commandcode",
modelId: "deepseek/deepseek-v4-flash",
});
});

test("discovers the live catalog with context windows and preserves slash ids", async () => {
globalThis.fetch = (async (input, init) => {
expect(String(input)).toBe("https://api.commandcode.ai/provider/v1/models");
Expand Down
Loading