From 3fba8ceb973b02e352361b6ec0f80a29fdd1c272 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Jan 2026 08:02:55 +0000 Subject: [PATCH] test(model): cover provider-less id fuzzy match --- src/auto-reply/reply.directive.test.ts | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/auto-reply/reply.directive.test.ts b/src/auto-reply/reply.directive.test.ts index b445c18a4..6000e5d56 100644 --- a/src/auto-reply/reply.directive.test.ts +++ b/src/auto-reply/reply.directive.test.ts @@ -1742,6 +1742,50 @@ describe("directive behavior", () => { }); }); + it("resolves provider-less exact model ids via fuzzy matching when unambiguous", async () => { + await withTempHome(async (home) => { + vi.mocked(runEmbeddedPiAgent).mockReset(); + const storePath = path.join(home, "sessions.json"); + + const res = await getReplyFromConfig( + { Body: "/model kimi-k2-0905-preview", From: "+1222", To: "+1222" }, + {}, + { + agents: { + defaults: { + model: { primary: "anthropic/claude-opus-4-5" }, + workspace: path.join(home, "clawd"), + models: { + "anthropic/claude-opus-4-5": {}, + "moonshot/kimi-k2-0905-preview": {}, + }, + }, + }, + models: { + mode: "merge", + providers: { + moonshot: { + baseUrl: "https://api.moonshot.ai/v1", + apiKey: "sk-test", + api: "openai-completions", + models: [{ id: "kimi-k2-0905-preview", name: "Kimi K2" }], + }, + }, + }, + session: { store: storePath }, + }, + ); + + const text = Array.isArray(res) ? res[0]?.text : res?.text; + expect(text).toContain("Model set to moonshot/kimi-k2-0905-preview"); + const store = loadSessionStore(storePath); + const entry = store["agent:main:main"]; + expect(entry.modelOverride).toBe("kimi-k2-0905-preview"); + expect(entry.providerOverride).toBe("moonshot"); + expect(runEmbeddedPiAgent).not.toHaveBeenCalled(); + }); + }); + it("supports fuzzy matches within a provider on /model provider/model", async () => { await withTempHome(async (home) => { vi.mocked(runEmbeddedPiAgent).mockReset();