Pedro Ribeiro
10/17/2025, 12:06 PMnodeLLMCompressHistory node exists, but the existing implementations of HistoryCompressionStrategy don't fit my use case. What would be the recommended approach to implement such use-case?
ThanksAnastasiia Zarechneva
10/17/2025, 12:56 PMHistoryCompressionStrategy.
As an example, you can override the compress method to filter received messages, find the ones of a type Message.Tool.Result and call a specific model to compress the content.
After this, you can use llmSession.rewritePrompt and pass the rewritten content (with compressed tool call results) to the next node.Pedro Ribeiro
10/17/2025, 1:01 PMMultiLLMPromptExecutor) and put back the previous prompt but with the tool call result replaced with the summary. Is that it?Anastasiia Zarechneva
10/17/2025, 1:10 PMI would need to temporarily set the prompt to only include the tool callNot exactly – you can address the messages by their type. In this case, your rewritten
compress function will look somewhat like this:
val messages = llmSession.prompt.messages
val rewritten = original.map { msg ->
if (msg is Message.Tool.Result) {
val compressed = <here you call your compression method> msg.copy(content = compressed)
} else msg
}
llmSession.rewritePrompt { prompt -> prompt.withMessages { rewritten } }
call the specific modelYup, you'll have to set it up in a
retrievalModel field when describing your compression node (basically the nodeLLMCompressHistory but with your custom strategy).
But you won't need to separately set it into the rewritten compress function, as nodeLLMCompressHistory already accepts a model name in a retrievalModel field.
put back the previous prompt but with the tool call replaced with the summaryYup, an this should be done in a rewritten
compress function – see the code example above 🙂Pedro Ribeiro
10/17/2025, 1:17 PMcompressPromptIntoTLDR? It accepts an llmSessionAnastasiia Zarechneva
10/17/2025, 2:08 PMcompress .Pedro Ribeiro
10/17/2025, 2:11 PM