Skip to content

interlens.context.sliding_window_policy

interlens.context.sliding_window_policy

SlidingWindowPolicy

SlidingWindowPolicy(
    keep_last: int, keep_system: bool = True
)

Bases: ContextPolicy

Keep the preserved framing plus the most recent keep_last turns; drop older turns.

keep_system=True (the default) preserves the system/moderator/private_context framing regardless of the window; set it False to also let framing fall outside the window (rarely wanted). Unlike DropOldestPolicy this is a fixed-size window rather than a fit-to-budget trim, so it's predictable turn-to-turn.

Source code in src/interlens/context/sliding_window_policy.py
def __init__(self, keep_last: int, keep_system: bool = True):
	self.keep_last = keep_last
	self.keep_system = keep_system