openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
13 lines (12 loc) • 711 B
JavaScript
//#region src/auto-reply/reply/history-limit.ts
const DEFAULT_GROUP_HISTORY_LIMIT = 50;
/** Hard cap for prompt-injected history windows. JSON-schema integer maximum is not a window. */
const MAX_PROMPT_HISTORY_LIMIT = 200;
/** Resolves one bounded observed-message window without rewriting saved configuration. */
function resolvePromptHistoryLimit(e, t = 50) {
const n = typeof e === "number" && Number.isInteger(e) && e >= Number.MAX_SAFE_INTEGER;
const r = typeof e === "number" && Number.isFinite(e) && !n ? e : t;
return Number.isFinite(r) ? Math.min(Math.max(0, Math.trunc(r)), MAX_PROMPT_HISTORY_LIMIT) : 0;
}
//#endregion
export { resolvePromptHistoryLimit as n, DEFAULT_GROUP_HISTORY_LIMIT as t };