Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Fix #5400: keep the DeepSeek refresh going past an unconfirmed model switch, cap the survey at 128 models

milind-soni32e95ee146c9
diff --git a/server/drivers/acp/deepseek.test.ts b/server/drivers/acp/deepseek.test.ts
index 3a2180bdfb..ec2e2f02c7 100644
--- a/server/drivers/acp/deepseek.test.ts
+++ b/server/drivers/acp/deepseek.test.ts
@@ -319,9 +319,10 @@ process.stdin.on("data", (chunk) => {
expect(catalog.options[2]).not.toHaveProperty("variants");
});
- it("rejects a model switch that was not confirmed instead of assigning another model's choices", async () => {
+ it("leaves a model whose switch was not confirmed without choices instead of assigning another model's", async () => {
const { cli, env } = fakeCli({ FAKE_DSH_MODE: "refuse-model" });
- await expect(fetchDeepSeekCatalog(cli, env, tmpdir())).rejects.toThrow(/did not confirm model/);
+ const catalog = await fetchDeepSeekCatalog(cli, env, tmpdir());
+ expect(catalog.options[1]).not.toHaveProperty("variants");
});
it("rejects within the timeout when dsh never answers", async () => {
diff --git a/server/drivers/acp/deepseek.ts b/server/drivers/acp/deepseek.ts
index b5a7630487..094de2f6e9 100644
--- a/server/drivers/acp/deepseek.ts
+++ b/server/drivers/acp/deepseek.ts
@@ -184,9 +184,12 @@ function catalogTimeoutMs(env: Record<string, string | undefined>): number {
return Number.isInteger(parsed) && parsed > 0 && parsed <= 2_147_483_647 ? parsed : DEEPSEEK_MODELS_DEFAULT_TIMEOUT_MS;
}
+const VARIANT_DISCOVERY_MODEL_LIMIT = 128;
+
/** Ask the installed dsh what it offers: initialize, session/new in `cwd`,
- * read each model's thinking choices, session/close. Rejects on any failure so the core keeps
- * the last usable catalog; never resolves to an empty or guessed list. */
+ * read each model's thinking choices (a model dsh won't switch to keeps none), session/close.
+ * Rejects on any other failure so the core keeps the last usable catalog; never resolves to an
+ * empty or guessed list. */
export function fetchDeepSeekCatalog(
cli: string,
env: Record<string, string | undefined>,
@@ -284,16 +287,16 @@ export function fetchDeepSeekCatalog(
return finish({ error: error instanceof Error ? error : new Error(String(error)) });
}
if (!sessionId) return finish({ catalog });
- const current = offeredWireValues(msg.result, "model").current;
- pendingModels.push(...catalog.options.filter((model) => deepseekWireValue(model.id) !== current));
+ if (catalog.options.length <= VARIANT_DISCOVERY_MODEL_LIMIT) {
+ const current = offeredWireValues(msg.result, "model").current;
+ pendingModels.push(...catalog.options.filter((model) => deepseekWireValue(model.id) !== current));
+ }
nextModel();
} else if (selectId && msg?.id === selectId && selectedModel) {
- if (offeredWireValues(msg.result, "model").current !== deepseekWireValue(selectedModel.id)) {
- send("session/close", { sessionId });
- return finish({ error: new Error(`dsh did not confirm model ${selectedModel.id} during discovery`) });
+ if (offeredWireValues(msg.result, "model").current === deepseekWireValue(selectedModel.id)) {
+ const variants = acpVariantOption(msg.result)?.options;
+ if (variants?.length) selectedModel.variants = variants;
}
- const variants = acpVariantOption(msg.result)?.options;
- if (variants?.length) selectedModel.variants = variants;
nextModel();
} else if (closeId && msg?.id === closeId) {
finish({ catalog: catalog! });