SummaryCompressor

org.llm4s.agent.harness.SummaryCompressor
See theSummaryCompressor companion object
@Experimental

Writes the summary a SummarizationMiddleware keeps (design ยง4.34).

compress returns a summary of previous - the summary so far, if any - followed by messages, the messages after it, never those it already covers: a summary is extended, not recomputed. It should stay within maxTokens estimated tokens at four characters a token; the middleware cuts what it returns to that bound either way.

A compressor that calls a model must call it through context.accounted(client), so the call is counted in the thread's usage, also when the model step later fails. Its result is pure state: when the model step runs again (recover), it is called again.

Attributes

Companion
object
Source
SummaryCompressor.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def compress(previous: Option[String], messages: Vector[Message], maxTokens: Int, context: ModelContext): Result[String]

Attributes

Source
SummaryCompressor.scala