SlidingWindowEventCompactor
An EventCompactor that compacts events in a sliding window over invocations.
Every compactionInterval new user-initiated invocations triggers a compaction over a window spanning the new invocations plus overlapSize preceding invocations from the prior compaction boundary. The overlap preserves context continuity across consecutive summaries.
Safety net
Before summarizing, the selected window is shrunk to its longest self-contained prefix so a compaction never splits an open interaction. Both a function call and a human-in-the-loop tool-confirmation request open an obligation keyed by the call ID, and a function response with the same ID closes it. The window is cut back to the last point where no obligation is still open, which guarantees:
no function call is summarized without its response,
no tool-confirmation request (
event.actions.requestedToolConfirmations) without its resolving response.
Functions
Compacts events in the given session. If compaction happened, the new compaction event will be appended to the given sessionService.