From a4385dc92052b8ddb411dd6dd7d9566a1aeca872 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Sun, 11 Jan 2026 22:18:15 +0530 Subject: [PATCH] fix: skip dm history limit for non-dm sessions --- src/agents/pi-embedded-runner.test.ts | 13 +++++++++++++ src/agents/pi-embedded-runner.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index 248869b90..c1a7ffae7 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -399,6 +399,19 @@ describe("getDmHistoryLimitFromSessionKey", () => { ).toBe(10); }); + it("returns undefined for non-dm session kinds", () => { + const config = { + slack: { dmHistoryLimit: 10 }, + telegram: { dmHistoryLimit: 15 }, + } as ClawdbotConfig; + expect( + getDmHistoryLimitFromSessionKey("agent:beta:slack:channel:C1", config), + ).toBeUndefined(); + expect( + getDmHistoryLimitFromSessionKey("telegram:slash:123", config), + ).toBeUndefined(); + }); + it("returns undefined for unknown provider", () => { const config = { telegram: { dmHistoryLimit: 15 } } as ClawdbotConfig; expect( diff --git a/src/agents/pi-embedded-runner.ts b/src/agents/pi-embedded-runner.ts index a6b845aa4..3932f49fd 100644 --- a/src/agents/pi-embedded-runner.ts +++ b/src/agents/pi-embedded-runner.ts @@ -475,6 +475,7 @@ export function getDmHistoryLimitFromSessionKey( // The userId may contain colons (e.g., email addresses), so join remaining parts const kind = providerParts[1]?.toLowerCase(); const userId = providerParts.slice(2).join(":"); + if (kind !== "dm") return undefined; // Helper to get limit with per-DM override support const getLimit = (