From 23717c503655aaa38c398bdd645c1d7875628e94 Mon Sep 17 00:00:00 2001 From: Marc Terns Date: Sun, 11 Jan 2026 08:55:32 -0600 Subject: [PATCH] test: add comprehensive per-DM override tests for all providers --- src/agents/pi-embedded-runner.test.ts | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index bdc71f860..248869b90 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -432,6 +432,50 @@ describe("getDmHistoryLimitFromSessionKey", () => { } }); + it("handles per-DM overrides for all supported providers", () => { + const providers = [ + "telegram", + "whatsapp", + "discord", + "slack", + "signal", + "imessage", + "msteams", + ] as const; + + for (const provider of providers) { + // Test per-DM override takes precedence + const configWithOverride = { + [provider]: { + dmHistoryLimit: 20, + dms: { user123: { historyLimit: 7 } }, + }, + } as ClawdbotConfig; + expect( + getDmHistoryLimitFromSessionKey( + `${provider}:dm:user123`, + configWithOverride, + ), + ).toBe(7); + + // Test fallback to provider default when user not in dms + expect( + getDmHistoryLimitFromSessionKey( + `${provider}:dm:otheruser`, + configWithOverride, + ), + ).toBe(20); + + // Test with agent-prefixed key + expect( + getDmHistoryLimitFromSessionKey( + `agent:main:${provider}:dm:user123`, + configWithOverride, + ), + ).toBe(7); + } + }); + it("returns per-DM override when set", () => { const config = { telegram: {