fix: skip dm history limit for non-dm sessions

This commit is contained in:
Ayaan Zaidi
2026-01-11 22:18:15 +05:30
parent 23717c5036
commit a4385dc920
2 changed files with 14 additions and 0 deletions

View File

@@ -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(

View File

@@ -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 = (