mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:02:42 +00:00
fix(discord): Apply historyLimit to channel/group sessions to prevent compaction bypass (openclaw#11356) thanks @shadril238
Verified: - pnpm build - pnpm check - pnpm test (ran; one unrelated existing failure in models forward-compat test) - pnpm vitest src/agents/pi-embedded-runner.history-limit-from-session-key.test.ts Co-authored-by: shadril238 <63901551+shadril238@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ec4da3aca9
commit
5378583da1
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
||||
|
||||
describe("getDmHistoryLimitFromSessionKey", () => {
|
||||
it("keeps backward compatibility for dm/direct session kinds", () => {
|
||||
const config = {
|
||||
channels: { telegram: { dmHistoryLimit: 10 } },
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(getDmHistoryLimitFromSessionKey("telegram:dm:123", config)).toBe(10);
|
||||
expect(getDmHistoryLimitFromSessionKey("telegram:direct:123", config)).toBe(10);
|
||||
});
|
||||
|
||||
it("returns historyLimit for channel and group session kinds", () => {
|
||||
const config = {
|
||||
channels: { discord: { historyLimit: 12, dmHistoryLimit: 5 } },
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(getDmHistoryLimitFromSessionKey("discord:channel:123", config)).toBe(12);
|
||||
expect(getDmHistoryLimitFromSessionKey("discord:group:456", config)).toBe(12);
|
||||
});
|
||||
|
||||
it("returns undefined for unsupported session kinds", () => {
|
||||
const config = {
|
||||
channels: { discord: { historyLimit: 12, dmHistoryLimit: 5 } },
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(getDmHistoryLimitFromSessionKey("discord:slash:123", config)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user