SlidingWindowStrategy
Defined in: agent/compaction/strategies/sliding-window.ts:36
Sliding window strategy - keeps recent turns, drops older ones.
This strategy:
- Groups messages into logical turns (user + assistant pairs)
- Keeps the
preserveRecentTurnsmost recent turns - Inserts a truncation marker at the beginning
- Requires no LLM call - very fast
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SlidingWindowStrategy():
SlidingWindowStrategy
Returns
Section titled “Returns”SlidingWindowStrategy
Properties
Section titled “Properties”
readonlyname:"sliding-window"="sliding-window"
Defined in: agent/compaction/strategies/sliding-window.ts:37
Human-readable name of the strategy
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”compact()
Section titled “compact()”compact(
messages,config,context):Promise<CompactionResult>
Defined in: agent/compaction/strategies/sliding-window.ts:39
Compact the given messages to fit within target token count.
Parameters
Section titled “Parameters”messages
Section titled “messages”Conversation history messages (excludes system/gadget base)
config
Section titled “config”Resolved compaction configuration
context
Section titled “context”Context including token counts and LLM client
Returns
Section titled “Returns”Promise<CompactionResult>
Compacted messages with metadata