CompactionConfig
Configuration for the memory.compaction() middleware.
Properties
Section titled “Properties”keepLast?
Section titled “keepLast?”
optionalkeepLast?:number
For “window”: keep last N messages.
keepLastToolResults?
Section titled “keepLastToolResults?”
optionalkeepLastToolResults?:number
For “clear-tool-results”: keep last N tool results verbatim. Default: 3.
keepRecentMessages?
Section titled “keepRecentMessages?”
optionalkeepRecentMessages?:number
For “summarize”/“hybrid”: keep last N messages verbatim.
maxTokens?
Section titled “maxTokens?”
optionalmaxTokens?:number
Maximum tokens for the context window. Default: 8192.
strategy?
Section titled “strategy?”
optionalstrategy?:CompactionStrategy
Compaction strategy. Default: “truncate”.
summaryModel?
Section titled “summaryModel?”
optionalsummaryModel?:string|LanguageModelV3
For “summarize”/“hybrid”: model for summaries. Default: agent’s own model.
tokenCounter?
Section titled “tokenCounter?”
optionaltokenCounter?:TokenCounter
Token counter function. Default: chars/4 heuristic.