Agents: summarize dropped messages during compaction safeguard pruning (#2418)

This commit is contained in:
jigar
2026-01-27 07:35:54 +05:30
committed by Shadow
parent 7d5221bcb2
commit dde9605874
9 changed files with 177 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
export type CompactionSafeguardRuntimeValue = {
maxHistoryShare?: number;
};
// Session-scoped runtime registry keyed by object identity.
// Follows the same WeakMap pattern as context-pruning/runtime.ts.
const REGISTRY = new WeakMap<object, CompactionSafeguardRuntimeValue>();
export function setCompactionSafeguardRuntime(
sessionManager: unknown,
value: CompactionSafeguardRuntimeValue | null,
): void {
if (!sessionManager || typeof sessionManager !== "object") {
return;
}
const key = sessionManager as object;
if (value === null) {
REGISTRY.delete(key);
return;
}
REGISTRY.set(key, value);
}
export function getCompactionSafeguardRuntime(
sessionManager: unknown,
): CompactionSafeguardRuntimeValue | null {
if (!sessionManager || typeof sessionManager !== "object") {
return null;
}
return REGISTRY.get(sessionManager as object) ?? null;
}