Class: Phronomy::Memory::Compression::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/memory/compression/base.rb

Overview

This class is abstract.

Subclass and implement #compress.

Abstract base class for compression strategies.

Two kinds of compression exist:

  • Content pruning (e.g. ToolOutputPruner) — modifies individual message content in-place (e.g. truncates oversized tool outputs). The original data loss is limited and intentional (tool outputs are auxiliary). These subclasses return { messages: Array, compaction: nil }.

  • Compaction (e.g. Summary) — replaces multiple messages with an LLM summary. Originals are preserved in Storage via a compaction record. These subclasses return { messages: Array, compaction: Hash } where compaction is { start_seq:, end_seq:, summary_text: }.

ConversationManager inspects the :compaction key and persists the record in Storage when present.

Direct Known Subclasses

Summary, ToolOutputPruner

Instance Method Summary collapse

Instance Method Details

#compress(thread_id:, messages:, seq_offset: 0) ⇒ Hash

Compress a message array and return a result hash.

Parameters:

  • thread_id (String)

    thread identifier (used by stateful compressors)

  • messages (Array)

    message history to compress

  • seq_offset (Integer) (defaults to: 0)

    seq number of messages[0] in the raw history

Returns:

  • (Hash)

    { messages: Array, compaction: Hash|nil }

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/phronomy/memory/compression/base.rb', line 31

def compress(thread_id:, messages:, seq_offset: 0)
  raise NotImplementedError, "#{self.class}#compress is not implemented"
end