Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix: minimal effort is the lowest rung, not the off switch
Jack Rudenko90ac5cb66a3f
diff --git a/packages/cli/src/adapters/base-api-format.ts b/packages/cli/src/adapters/base-api-format.tsindex 37bed32f..e2b51d75 100644--- a/packages/cli/src/adapters/base-api-format.ts+++ b/packages/cli/src/adapters/base-api-format.ts@@ -595,17 +595,15 @@ export abstract class BaseAPIFormat implements APIFormat, ModelDialect {// endpoint's own default is a better answer than a level we invented.if (!effort) return request;- if (effort === "none" || effort === "minimal") {- // `mandatory` means the model cannot run with reasoning off, so a- // `disabled` here is a request the provider must reject. Honour the- // intent as far as the model allows: the lowest level it advertises.- if (reasoning?.mandatory) {- return this.enableAnthropicEffort(request, effort, reasoning, "mandatory reasoning");- }+ if (this.meansReasoningOff(effort, reasoning)) {request.thinking = { type: "disabled" };log(`[${this.getName()}] effort ${effort} -> thinking.type: disabled for ${this.modelId}`);return request;}+ // `none`/`minimal` that survived {@link meansReasoningOff} is a request for+ // the LEAST thinking this model offers, not for none: a mandatory model, or+ // `minimal` where a depth control exists. Both fall through to the+ // control-driven dispatch below, which clamps to the advertised ladder.// ── Control-driven dispatch ─────────────────────────────────────────────//@@ -761,6 +759,43 @@ export abstract class BaseAPIFormat implements APIFormat, ModelDialect {* in the models-index catalog; do NOT hardcode a per-model override here, or* claudish stops reflecting the catalog it is supposed to be driven by.*/+ /**+ * Does this effort level mean "send the OFF switch" for THIS model?+ *+ * One rule, shared by every wire, because the same mistake was made on four of+ * them independently: `effort === "none" || effort === "minimal"` → emit the+ * provider's disable value. That collapses two of claudish's seven levels into+ * one, and it is wrong twice over.+ *+ * **`minimal` is not `none`.** claudish publishes both. `none` means do not+ * reason; `minimal` means reason as little as possible. Where the model has a+ * depth control, "as little as possible" is its lowest rung — that is what the+ * word asks for, and {@link clampToAdvertisedEffort} already computes it.+ * Sending the off-switch instead throws away the distinction the two level+ * names exist to express.+ *+ * **Some models cannot be switched off at all.** The catalog says so with+ * `mandatory: true`, and the provider enforces it. Measured on Z.AI 2026-09-21:+ * `{"thinking":{"type":"disabled"}}` for glm-5.3 → `400 code 1210 "This model+ * always engages in thinking and cannot be disabled"`, while the same request+ * with the switch on and `reasoning_effort: "low"` → 200. The catalog publishes+ * `mandatory: true` for glm-5.3 and glm-5.3-flash, so this never needed a guess.+ *+ * The remaining case is a model with an on/off switch and no depth control and+ * no mandate. There "as little as possible" and "none" really are the same+ * request, because the wire has no third value to send — so both disable, and+ * behaviour for those models is unchanged.+ */+ protected meansReasoningOff(+ effort: EffortLevel,+ reasoning: ReasoningCapability | undefined+ ): boolean {+ if (effort !== "none" && effort !== "minimal") return false;+ if (reasoning?.mandatory) return false;+ if (effort === "minimal" && (reasoning?.efforts?.length ?? 0) > 0) return false;+ return true;+ }+protected clampToAdvertisedEffort(requested: EffortLevel,reasoning: ReasoningCapabilitydiff --git a/packages/cli/src/adapters/deepseek-model-dialect.ts b/packages/cli/src/adapters/deepseek-model-dialect.tsindex 55042bae..ca9e0360 100644--- a/packages/cli/src/adapters/deepseek-model-dialect.ts+++ b/packages/cli/src/adapters/deepseek-model-dialect.ts@@ -36,7 +36,10 @@ export class DeepSeekModelDialect extends BaseAPIFormat {const effort = this.resolveEffortLevel(originalRequest);if (effort && this.acceptsReasoningControls()) {- if (effort === "none" || effort === "minimal") {+ // Same rule as every other wire: `minimal` is the lowest rung where one+ // exists, and a model the catalog marks `mandatory` is never sent an+ // off-switch. See BaseAPIFormat.meansReasoningOff.+ if (this.meansReasoningOff(effort, this.lookupReasoningCapability())) {// Disable thinking on V4+.request.thinking = { type: "disabled" };// Never leave a depth knob contradicting the off-switch — the same rulediff --git a/packages/cli/src/adapters/effort-mapping.test.ts b/packages/cli/src/adapters/effort-mapping.test.tsindex d2472172..db4639b1 100644--- a/packages/cli/src/adapters/effort-mapping.test.ts+++ b/packages/cli/src/adapters/effort-mapping.test.ts@@ -392,6 +392,23 @@ function qwenPrep(modelId: string, req: any): any {return (fmt as any).prepareRequest({}, req);}+class StubbedQwen extends QwenModelDialect {+ constructor(+ modelId: string,+ private readonly stub: any+ ) {+ super(modelId);+ }++ protected override lookupReasoningCapability(): any {+ return this.stub;+ }+}++function stubbedQwenPrep(modelId: string, stub: any, originalRequest: any): any {+ return new StubbedQwen(modelId, stub).prepareRequest({}, originalRequest);+}+describe("Qwen enable_thinking + thinking_budget", () => {test("none/minimal → enable_thinking false", () => {expect(qwenPrep("qwen3-max", { output_config: { effort: "none" } }).enable_thinking).toBe(@@ -423,6 +440,15 @@ describe("Qwen enable_thinking + thinking_budget", () => {expect(out.enable_thinking).toBe(true);expect(out.thinking_budget).toBeUndefined();});++ test("mandatory ladder never sets enable_thinking false", () => {+ for (const effort of ["none", "minimal"] as const) {+ const out = stubbedQwenPrep("qwen3-mandatory", MANDATORY_REASONING_LADDER, {+ output_config: { effort },+ });+ expect(out.enable_thinking).toBe(true);+ }+ });});// ─── Part 2F: GLM ─────────────────────────────────────────────────────────@@ -486,6 +512,25 @@ const CATALOG = {"glm-4-plus": undefined,};+const MANDATORY_REASONING_LADDER = {+ supported: true,+ control: "effort",+ mandatory: true,+ efforts: ["max", "high", "low"],+ defaultEffort: "max",+};++const OPTIONAL_REASONING_LADDER = {+ ...MANDATORY_REASONING_LADDER,+ mandatory: false,+};++const OPTIONAL_THINKING_TOGGLE = {+ supported: true,+ control: "toggle",+ mandatory: false,+};+function stubbedGlmPrep(modelId: keyof typeof CATALOG | string,stub: any,@@ -556,7 +601,7 @@ describe("GLM catalog-driven thinking toggles newer than 4.6", () => {describe("GLM-5.2 catalog-driven reasoning_effort", () => {test.each([["none", { type: "disabled" }, undefined],- ["minimal", { type: "disabled" }, undefined],+ ["minimal", { type: "enabled" }, "high"], // A ladder makes minimal the floor, unlike none.["low", { type: "enabled" }, "high"],["medium", { type: "enabled" }, "high"],["high", { type: "enabled" }, "high"],@@ -608,6 +653,50 @@ describe("GLM-5.2 catalog-driven reasoning_effort", () => {});});+describe("shared reasoning-off rule on the GLM wire", () => {+ test("mandatory ladder maps none and minimal to enabled low", () => {+ for (const effort of ["none", "minimal"] as const) {+ const out = stubbedGlmPrep("glm-5.3", MANDATORY_REASONING_LADDER, {+ output_config: { effort },+ });+ expect(out.thinking).toEqual({ type: "enabled" });+ expect(out.reasoning_effort).toBe("low");+ }+ });++ test("optional ladder keeps none off but maps minimal to its lowest rung", () => {+ const none = stubbedGlmPrep("glm-optional-ladder", OPTIONAL_REASONING_LADDER, {+ output_config: { effort: "none" },+ });+ const minimal = stubbedGlmPrep("glm-optional-ladder", OPTIONAL_REASONING_LADDER, {+ output_config: { effort: "minimal" },+ });++ expect(none.thinking).toEqual({ type: "disabled" });+ expect(none.reasoning_effort).toBeUndefined();+ expect(minimal.thinking).toEqual({ type: "enabled" });+ expect(minimal.reasoning_effort).toBe("low");+ expect(minimal.thinking).not.toEqual(none.thinking);+ });++ test("toggle-only keeps none and minimal off", () => {+ const none = stubbedGlmPrep("glm-4.7", OPTIONAL_THINKING_TOGGLE, {+ output_config: { effort: "none" },+ });+ const minimal = stubbedGlmPrep("glm-4.7", OPTIONAL_THINKING_TOGGLE, {+ output_config: { effort: "minimal" },+ });+ const ladderMinimal = stubbedGlmPrep("glm-optional-ladder", OPTIONAL_REASONING_LADDER, {+ output_config: { effort: "minimal" },+ });++ expect(none.thinking).toEqual({ type: "disabled" });+ expect(minimal.thinking).toEqual({ type: "disabled" });+ // The matching toggle results are deliberate, not a collapse of minimal into none.+ expect(minimal.thinking).not.toEqual(ladderMinimal.thinking);+ });+});+describe("GLM legacy stripping behavior", () => {test("glm-4-plus strips incoming thinking even with a high effort signal", () => {const out = stubbedGlmPrep(@@ -693,6 +782,23 @@ function dsPrep(modelId: string, req: any): any {return (fmt as any).prepareRequest({}, req);}+class StubbedDeepSeek extends DeepSeekModelDialect {+ constructor(+ modelId: string,+ private readonly stub: any+ ) {+ super(modelId);+ }++ protected override lookupReasoningCapability(): any {+ return this.stub;+ }+}++function stubbedDsPrep(modelId: string, stub: any, originalRequest: any): any {+ return new StubbedDeepSeek(modelId, stub).prepareRequest({}, originalRequest);+}+describe("DeepSeek V4 reasoning_effort + thinking", () => {// Seed the catalog because the dialect consults it before its name rule.let cleanupCatalog: (() => void) | undefined;@@ -779,6 +885,16 @@ describe("DeepSeek V4 reasoning_effort + thinking", () => {cleanupOpinionCatalog();}});++ test("mandatory ladder never sends thinking disabled", () => {+ for (const effort of ["none", "minimal"] as const) {+ const out = stubbedDsPrep("deepseek-v4-mandatory", MANDATORY_REASONING_LADDER, {+ output_config: { effort },+ });+ expect(out.thinking).not.toEqual({ type: "disabled" });+ expect(out.reasoning_effort).toBe("low");+ }+ });});// ─── Part 2H: MiniMax ─────────────────────────────────────────────────────diff --git a/packages/cli/src/adapters/glm-model-dialect.ts b/packages/cli/src/adapters/glm-model-dialect.tsindex e872da59..9eed3052 100644--- a/packages/cli/src/adapters/glm-model-dialect.ts+++ b/packages/cli/src/adapters/glm-model-dialect.ts@@ -55,7 +55,13 @@ export class GLMModelDialect extends BaseAPIFormat {const reasoning = this.lookupReasoningCapability();if (effort && this.acceptsThinkingToggle(reasoning)) {- if (effort === "none" || effort === "minimal") {+ // `meansReasoningOff`, not `effort === "none" || effort === "minimal"`.+ // The catalog publishes `mandatory: true` for glm-5.3 and glm-5.3-flash,+ // and Z.AI answers a `disabled` on those with `400 code 1210 "This model+ // always engages in thinking and cannot be disabled"`. v10.0.1 stopped the+ // PROBE asking for it; this is the same fault on the request path every+ // `glm@` and `glm-coding@` turn takes.+ if (this.meansReasoningOff(effort, reasoning)) {request.thinking = { type: "disabled" };// Never leave a depth knob contradicting the off-switch.if (request.reasoning_effort !== undefined) delete request.reasoning_effort;diff --git a/packages/cli/src/adapters/qwen-model-dialect.ts b/packages/cli/src/adapters/qwen-model-dialect.tsindex cb5a3eeb..9c8b4425 100644--- a/packages/cli/src/adapters/qwen-model-dialect.ts+++ b/packages/cli/src/adapters/qwen-model-dialect.ts@@ -81,7 +81,11 @@ export class QwenModelDialect extends BaseAPIFormat {const effort = this.resolveEffortLevel(originalRequest);if (!effort) return request;- if (effort === "none" || effort === "minimal") {+ // Same rule as every other wire (BaseAPIFormat.meansReasoningOff): `minimal`+ // is the lowest rung where the catalog advertises one, and a model marked+ // `mandatory` is never sent `enable_thinking: false`. DashScope serves GLM+ // alongside Qwen on this wire, so the mandatory case is reachable here too.+ if (this.meansReasoningOff(effort, this.lookupReasoningCapability())) {request.enable_thinking = false;log(`[QwenModelDialect] effort ${effort} -> enable_thinking: false for ${this.modelId}`);} else {