From 6caa0dcbc13ea303cc4b86efdf485e0cb5d4b3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Thu, 26 Nov 2026 21:32:48 +0000 Subject: [PATCH] fix(acp): allow _lembas/configure model switch on serve --stdio (v2.0.0-beta.16) --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- src/acp/agent.ts | 31 ++++++++++++++++++++++--------- tests/acp-editor.test.ts | 15 +++++++++++++++ 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d268f0..f7613b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to LLeMbas CLI. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses [Semantic Versioning](https://semver.org/). +## [2.0.0-beta.16] — 2026-11-26 + +### Fixed + +- **IDE model switching on `lembas serve --stdio`** (`_lembas/configure`): no + longer requires a linked server instance connection when changing the active + session's model from an editor client (VS Code / VSCodium / Neovim), resolving + against the device's signed-in server models instead. + ## [2.0.0-beta.15] — 2026-11-26 ### Added diff --git a/package.json b/package.json index 64c04f4..78d02c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lembas-cli", - "version": "2.0.0-beta.15", + "version": "2.0.0-beta.16", "description": "LLeMbas CLI: a terminal coding agent and project manager for a LLeMbas server — OpenTUI, memory, skills, MCP, git-native.", "license": "MIT", "private": true, diff --git a/src/acp/agent.ts b/src/acp/agent.ts index d452e19..17b022e 100644 --- a/src/acp/agent.ts +++ b/src/acp/agent.ts @@ -870,15 +870,28 @@ export class AcpAgent { const t = this.terminalFor(p) if (t) return t.client.request("hub/configure", { sessionId: t.sessionId, model: this.refFor(p?.model), effort: p?.effort }, 30_000) const s = this.get(p) - const ref = p?.model !== undefined ? this.chatModel(p.model) : undefined - if (ref && s.app.canonicalRef(ref) !== s.app.engine.model.ref) { - const conn = s.app.loaded.connections[this.instanceConnection!] - const id = s.app.canonicalRef(ref) - if (!conn) throw new RpcError(INVALID_PARAMS, `this device is not logged in to ${this.instanceConnection}, so it cannot run ${p.model}`) - if (Object.keys(conn.models).length && !conn.models[id]) throw new RpcError(INVALID_PARAMS, `${conn.webui?.name ?? this.instanceConnection} does not serve ${p.model} to this device`) - // The person's change is the directory's model from now (spec 3.9.0) — a schedule's session - // apart, which the app was told never to remember. - s.app.chooseModel(ref) + if (p?.model !== undefined) { + if (this.instanceConnection || this.limits) { + const ref = this.chatModel(p.model) + if (s.app.canonicalRef(ref) !== s.app.engine.model.ref) { + const conn = s.app.loaded.connections[this.instanceConnection!] + const id = s.app.canonicalRef(ref) + if (!conn) throw new RpcError(INVALID_PARAMS, `this device is not logged in to ${this.instanceConnection}, so it cannot run ${p.model}`) + if (Object.keys(conn.models).length && !conn.models[id]) throw new RpcError(INVALID_PARAMS, `${conn.webui?.name ?? this.instanceConnection} does not serve ${p.model} to this device`) + // The person's change is the directory's model from now (spec 3.9.0) — a schedule's session + // apart, which the app was told never to remember. + s.app.chooseModel(ref) + } + } else { + // Local stdio editor client: resolve against the device's own signed-in models. + const raw = typeof p.model === "string" ? p.model.trim() : "" + if (!raw) throw new RpcError(INVALID_PARAMS, "model must be a non-empty string") + try { + if (s.app.canonicalRef(raw) !== s.app.engine.model.ref) s.app.chooseModel(raw) + } catch (e) { + throw new RpcError(INVALID_PARAMS, (e as Error).message) + } + } } const effort = effortOf(p?.effort) // A level the model does not offer is read as its start level; the answer says the one used. diff --git a/tests/acp-editor.test.ts b/tests/acp-editor.test.ts index 832faa4..ead2b47 100644 --- a/tests/acp-editor.test.ts +++ b/tests/acp-editor.test.ts @@ -861,3 +861,18 @@ test("a client that writes puts the text into its buffer and saves before answer expect(readFileSync(file, "utf8")).toBe("a third\n") expect(readFileSync(join(root, "b.txt"), "utf8")).toBe("new\n") }) + +test("_lembas/configure on serve --stdio switches the session model without an instance device link", async () => { + fake = fakeProvider([{ chunks: [delta({ content: "switched" })] }]) + config(fake.url) + const root = project() + const { c } = await editor() + const s: any = await c.request("session/new", { cwd: root }) + expect(s._meta.lembas.model).toBe("f/m") + const res: any = await c.request("_lembas/configure", { sessionId: s.sessionId, model: "f/deep" }) + expect(res.model).toBe("f/deep") + await c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "hi" }] }) + expect(fake.requests.at(-1).model).toBe("f/deep") + // Empty model string is rejected cleanly. + expect((await refusal(c.request("_lembas/configure", { sessionId: s.sessionId, model: " " }))).message).toContain("non-empty") +})