Skip to content

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

#6436: an OpenAI or OpenRouter level the model no longer lists is left out, as before

milind-sonif3c70fccc5cf
diff --git a/server/drivers/openai-compat-reasoning.test.ts b/server/drivers/openai-compat-reasoning.test.ts
index 6beb38afd8..6414c53cd5 100644
--- a/server/drivers/openai-compat-reasoning.test.ts
+++ b/server/drivers/openai-compat-reasoning.test.ts
@@ -57,9 +57,9 @@ describe("reasoning effort on an API key", () => {
});
await turn(instance, "gpt-5.2", "low");
await turn(instance, "gpt-5.2");
- expect(await turn(instance, "gpt-4.1", "low")).toMatchObject({ ok: false });
- expect(await turn(instance, "gpt-5.2", "max")).toMatchObject({ ok: false });
- expect(chats.map((chat) => chat.reasoning_effort)).toEqual(["low", undefined]);
+ expect(await turn(instance, "gpt-4.1", "low"), "a level the model does not list is left out").toMatchObject({ ok: true });
+ expect(await turn(instance, "gpt-5.2", "max")).toMatchObject({ ok: true });
+ expect(chats.map((chat) => chat.reasoning_effort)).toEqual(["low", undefined, undefined, undefined]);
} finally { await instance.dispose(); }
});
@@ -71,9 +71,9 @@ describe("reasoning effort on an API key", () => {
expect(variantsOf(instance)).toMatchObject({ "acme/thinker": ["low", "medium", "high", "xhigh", "max"], "acme/plain": undefined });
await turn(instance, "acme/thinker", "high");
await turn(instance, "acme/thinker", "max");
- expect(await turn(instance, "acme/thinker", "ultra")).toMatchObject({ ok: false });
- expect(await turn(instance, "acme/plain", "high")).toMatchObject({ ok: false });
- expect(chats.map((chat) => chat.reasoning)).toEqual([{ effort: "high" }, { effort: "max" }]);
+ expect(await turn(instance, "acme/thinker", "ultra"), "a level the model does not list is left out").toMatchObject({ ok: true });
+ expect(await turn(instance, "acme/plain", "high")).toMatchObject({ ok: true });
+ expect(chats.map((chat) => chat.reasoning)).toEqual([{ effort: "high" }, { effort: "max" }, undefined, undefined]);
expect(chats.every((chat) => chat.reasoning_effort === undefined)).toBe(true);
} finally { await instance.dispose(); }
});
diff --git a/server/drivers/openai-compat.ts b/server/drivers/openai-compat.ts
index 0d438509bf..8b02d46c67 100644
--- a/server/drivers/openai-compat.ts
+++ b/server/drivers/openai-compat.ts
@@ -267,13 +267,13 @@ export const OpenAICompatDriver: ProviderDriver<OpenAICompatConfig> = {
const takesEffort = (id: string, row: OpenRouterModelRow) => config.catalog === "openai" ? OPENAI_REASONING.test(id)
: openRouter && Array.isArray(row.supported_parameters) && row.supported_parameters.includes("reasoning");
const apiEffort = (model: string, variant: string | undefined) => {
- const explicit = reasoningBody(reasoningFor(model), variant);
+ const selected = reasoningFor(model);
+ const listed = catalog.options.find((option) => option.id === model)?.variants;
+ // An OpenAI or OpenRouter level the model no longer lists is left out, as before, so a saved level never fails the turn.
+ if (variant && (config.catalog === "openai" || openRouter) && !(selected?.choices ?? listed ?? []).some((choice) => choice.id === variant)) return {};
+ const explicit = reasoningBody(selected, variant);
if (explicit) return explicit;
- if (!variant) return {};
- if (!catalog.options.find((option) => option.id === model)?.variants?.some((choice) => choice.id === variant)) {
- if (config.catalog === "openai" || openRouter) throw new Error("Selected reasoning effort is unavailable for this model. Refresh models and choose a supported effort or use the provider default.");
- return {};
- }
+ if (!variant || !listed?.some((choice) => choice.id === variant)) return {};
return config.catalog === "openai" ? { reasoning_effort: variant } : openRouter ? { reasoning: { effort: variant } } : {};
};