Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
feat(effort): add --accept-served-model for reasoning-off served by another model
Jack Rudenkoe436e8e6b5e5
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.tsindex 387df3f4..0d3bcb1d 100644--- a/packages/cli/src/cli.ts+++ b/packages/cli/src/cli.ts@@ -264,6 +264,7 @@ export const CLAUDISH_FLAG_ARITY: Readonly<Record<string, ClaudishFlagArity>> ="--effort-override": "value","--pro-on-ultracode": "none","--no-pro-on-ultracode": "none",+ "--accept-served-model": "none","--op-env": "value","--op": "value","--cost-track": "none",@@ -766,6 +767,13 @@ export async function parseArgs(args: string[]): Promise<ClaudishConfig> {} else if (arg === "--no-pro-on-ultracode") {// Escape hatch when it is enabled via config/env: off for this run.config.proOnUltracode = false;+ } else if (arg === "--accept-served-model") {+ // Some connections serve reasoning-off with a DIFFERENT model (Kimi Code+ // k3: thinking off is served by K2.8 Preview — the catalog's+ // `served_model_changes` warning). Without this flag claudish keeps+ // reasoning on and says why; with it, it sends the disable. Exported as+ // env so child claudish processes inherit the choice.+ process.env.CLAUDISH_ACCEPT_SERVED_MODEL = "1";} else if (arg === "--op-env" || arg.startsWith("--op-env=")) {// The actual 1Password Environment read happens early in index.ts// (highest priority). Here we only consume the flag + its value so it@@ -2306,6 +2314,7 @@ ${h("OPTIONS")}${green("--effort-override")} ${yellow("<level>")} Pin reasoning effort verbatim, skipping the per-model clamp${green("--pro-on-ultracode")} Apply the model's catalog preset while in ultracode (opt-in)${green("--no-pro-on-ultracode")} Force that off for this run (when enabled in config/env)+ ${green("--accept-served-model")} Allow a reasoning-off that the connection serves with another model${green("-y, --auto-approve")} Skip permission prompts (--dangerously-skip-permissions)${green("--no-auto-approve")} Explicitly enable permission prompts (default)${green("--dangerous")} Pass --dangerouslyDisableSandbox to Claude Codediff --git a/packages/cli/src/handlers/composed-handler.ts b/packages/cli/src/handlers/composed-handler.tsindex 07d39272..520215b4 100644--- a/packages/cli/src/handlers/composed-handler.ts+++ b/packages/cli/src/handlers/composed-handler.ts@@ -1174,6 +1174,9 @@ export class ComposedHandler implements ModelHandler {if (wire?.status === "known") {const choices: WireChoices = {...wireChoicesFromClaudeRequest(claudeRequest, this.options.effortOverride),+ // `--accept-served-model` (or CLAUDISH_ACCEPT_SERVED_MODEL=1): the user+ // named the swap, so a part the catalog warns about may be sent.+ acceptServedModelChange: process.env.CLAUDISH_ACCEPT_SERVED_MODEL === "1",};const markers = wireMarkerContext.getStore();const wireMode = this.options.wireMode ?? markers?.mode;diff --git a/packages/cli/src/providers/accept-served-model.test.ts b/packages/cli/src/providers/accept-served-model.test.tsnew file mode 100644index 00000000..687c1f5a--- /dev/null+++ b/packages/cli/src/providers/accept-served-model.test.ts@@ -0,0 +1,69 @@+import { expect, test } from "bun:test";+import { mkdtempSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";++test("parseArgs exports served-model consent and step 5w honors it for Kimi Code", () => {+ const home = mkdtempSync(join(tmpdir(), "accept-served-"));+ const source = new URL("../", import.meta.url).pathname;+ const fixture = new URL(+ "../test-fixtures/catalog-v3/wire-g-20261012101007285-7770c36e.json",+ import.meta.url+ ).pathname;+ try {+ const child = Bun.spawnSync(+ [+ process.execPath,+ "--eval",+ `+ const { Hono } = await import("hono");+ const { parseArgs } = await import(${JSON.stringify(source + "cli.ts")});+ const { buildWireHandler } = await import(${JSON.stringify(source + "providers/wire-handler.ts")});+ const { getProviderByName, toRemoteProvider } = await import(${JSON.stringify(source + "providers/provider-definitions.ts")});+ const previousEnv = process.env.CLAUDISH_ACCEPT_SERVED_MODEL;+ const originalFetch = globalThis.fetch;+ const bodies = [];+ globalThis.fetch = async (_url, init) => { bodies.push(JSON.parse(init.body)); return new Response("captured", {status: 400}); };+ try {+ delete process.env.CLAUDISH_ACCEPT_SERVED_MODEL;+ const built = await buildWireHandler({ provider: toRemoteProvider(getProviderByName("kimi-coding")), modelName: "k3", targetModel: "kimi-coding@k3", apiKey: "fake", port: 0, catalogCachePath: ${JSON.stringify(fixture)}, sharedOpts: {} }, "kimi-coding");+ if (built.kind !== "handler") throw new Error(JSON.stringify(built));+ try {+ const app = new Hono();+ app.post("/", c => built.handler.handle(c, { max_tokens: 512, messages: [{ role: "user", content: "hello" }], thinking: {type: "disabled"} }));+ await app.request("/", {method: "POST"});+ const config = await parseArgs(["--accept-served-model", "--model", "kimi-coding@k3", "hello"]);+ const accepted = process.env.CLAUDISH_ACCEPT_SERVED_MODEL;+ await app.request("/", {method: "POST"});+ console.log(JSON.stringify({ accepted, args: config.claudeArgs, bodies }));+ } finally { await built.handler.shutdown(); }+ } finally {+ globalThis.fetch = originalFetch;+ if (previousEnv === undefined) delete process.env.CLAUDISH_ACCEPT_SERVED_MODEL;+ else process.env.CLAUDISH_ACCEPT_SERVED_MODEL = previousEnv;+ }+ `,+ ],+ {+ env: {+ PATH: process.env.PATH,+ HOME: home,+ CLAUDISH_DISABLE_CATALOG_WARM: "1",+ CLAUDISH_DISABLE_KEYCHAIN: "1",+ CLAUDISH_DISABLE_OP: "1",+ },+ stdout: "pipe",+ stderr: "pipe",+ }+ );+ expect(child.exitCode, child.stderr.toString()).toBe(0);+ const result = JSON.parse(child.stdout.toString());+ expect(result.accepted).toBe("1");+ expect(result.args).toEqual(["hello"]);+ expect(result.bodies).toHaveLength(2);+ expect(result.bodies[0].reasoning_effort).toBe("low");+ expect(result.bodies[1].reasoning_effort).toBe("none");+ } finally {+ rmSync(home, { recursive: true, force: true });+ }+});diff --git a/packages/cli/src/providers/wire-request.ts b/packages/cli/src/providers/wire-request.tsindex 21b0ceab..836df922 100644--- a/packages/cli/src/providers/wire-request.ts+++ b/packages/cli/src/providers/wire-request.ts@@ -260,7 +260,7 @@ function applyReasoning(const warning = warningFor(reasoning.warnings, "disable");if (warning && !choices.acceptServedModelChange) {result.notes.push(- `turning reasoning off is served by ${warning.servedModel} on this connection; reasoning kept on (${warning.code})`+ `turning reasoning off is served by ${warning.servedModel} on this connection; reasoning kept on (${warning.code}; --accept-served-model allows it)`);off = false;} else {