From 1cfebfe0e1cd8d1966a4f389ee6c0b9832c62418 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 24 Apr 2026 18:36:16 +0100 Subject: [PATCH] test: cover Telegram topic model switches --- ...ets-active-session-native-stop.e2e.test.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts index 716c27243c1..d5415a3fdfb 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts @@ -684,6 +684,65 @@ describe("trigger handling", () => { }); }); + it("applies native model changes to Telegram topic thread sessions", async () => { + await withTempHome(async (home) => { + const cfg = makeCfg(home); + cfg.agents = { + ...cfg.agents, + defaults: { + ...cfg.agents?.defaults, + models: { + ...cfg.agents?.defaults?.models, + "deepseek/deepseek-v4-pro": {}, + }, + }, + }; + cfg.session = { ...cfg.session, store: join(home, "native-model-thread.sessions.json") }; + const runEmbeddedPiAgentMock = getRunEmbeddedPiAgentMock(); + runEmbeddedPiAgentMock.mockReset(); + const storePath = requireSessionStorePath(cfg); + const slashSessionKey = "agent:main:telegram:slash:7595562691"; + const targetSessionKey = "agent:main:main:thread:7595562691:12812"; + + await fs.writeFile( + storePath, + JSON.stringify({ + [targetSessionKey]: { + sessionId: "session-target", + updatedAt: Date.now(), + providerOverride: "zai", + modelOverride: "glm-5.1", + }, + }), + ); + + const res = await getReplyFromConfig( + makeNativeTelegramCommandMessage({ + body: "/model deepseek/deepseek-v4-pro", + slashSessionKey, + targetSessionKey, + }), + {}, + cfg, + ); + + expect(maybeReplyText(res)).toContain("Model set to deepseek/deepseek-v4-pro"); + + const store = loadSessionStore(storePath); + expect(store[targetSessionKey]?.providerOverride).toBe("deepseek"); + expect(store[targetSessionKey]?.modelOverride).toBe("deepseek-v4-pro"); + expect(store[slashSessionKey]).toBeUndefined(); + + await expectNextRunUsesTargetSession( + { cfg, targetSessionKey, runEmbeddedPiAgentMock }, + { + provider: "deepseek", + model: "deepseek-v4-pro", + }, + ); + }); + }); + it("applies native model auth profile overrides to the target session", async () => { await withTempHome(async (home) => { const cfg = makeCfg(home);