openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
10 lines (9 loc) • 478 B
JavaScript
//#region src/agents/agent-compaction-constants.ts
const MAX_COMPACTION_RESERVE_RATIO = .25;
/** Caps compaction headroom so prompts retain at least three quarters of the model window. */
function resolveEffectiveCompactionReserveTokens(e) {
const t = Math.max(1, Math.floor(e.contextTokenBudget));
return Math.min(Math.max(0, Math.floor(e.reserveTokens)), Math.floor(t * MAX_COMPACTION_RESERVE_RATIO));
}
//#endregion
export { resolveEffectiveCompactionReserveTokens as t };