FactRetrievalHistoryCompressionStrategy
A history compression strategy that extracts structured facts about predefined concepts from the current conversation history using an LLM, then replaces the full history with a compact assistant message containing those extracted facts.
For each Concept in concepts, the strategy issues a separate structured LLM request against a snapshot of the current conversation (wrapped in XML tags) to extract either a single fact (FactType.SINGLE) or multiple facts (FactType.MULTIPLE). The original prompt and model are restored after each extraction so that the session state is not mutated.
The resulting compressed prompt contains:
All original system messages
The first user message (if present)
Any provided memoryMessages
A single assistant message with a
[CONTEXT RESTORATION]block listing the extracted facts and the approximate number of tool interactions that occurred before compression
If no facts are extracted for any concept, the strategy delegates to fallback (by default NoCompression, which leaves the prompt unchanged). Provide a different strategy (e.g. a TLDR-based one) to guarantee the history still shrinks when no configured concept matched.
Parameters
A list of Concept objects that define the topics for which facts should be extracted.
Strategy used when no facts are extracted for any concept. Defaults to NoCompression.