WholeHistoryMultipleSystemMessages

WholeHistoryMultipleSystemMessages is a concrete implementation of the HistoryCompressionStrategy that handles scenarios where the conversation history contains multiple system messages.

This strategy:

  1. Splits the history into blocks based on system message boundaries

  2. Processes each block separately to generate TL;DR summaries

  3. Maintains the chronological order of system messages while compressing the conversation

  4. Preserves memory messages only in the first block to maintain context

System1, User1, Assistant, ToolCall, ToolResult, System2, User2, Assistant, User3, System3, Assistant, System4 ->System1, User1, Memory, TLDR(System1, User1, Assistant, ToolCall, ToolResult), System2, User2, TLDR(System2, User2, Assistant, User3), System3, Assistant, TLDR(System3, Assistant) System4, TLDR(System4)

Functions

Link copied to clipboard
open suspend override fun compress(llmSession: AIAgentLLMWriteSession, memoryMessages: List<Message>)

Compresses and adjusts the prompt for the agent's write session by summarizing and incorporating memory messages optionally.