class

Crig::Memory::CompactingMemory(M, P, C)

Inherits Crig::Memory::ConversationMemory < Reference < Object

A ConversationMemory adapter that wraps a backend with a MemoryPolicy and a Compactor, replacing truncated turns with a summary message spliced at the front of the loaded history.

The loaded history shape is [summary_message, ...kept_window] when any compaction has occurred, or just kept_window otherwise. The summary is recomputed on every load that produces newly-evicted messages, folding older summaries into newer ones via the compactor's carry_over parameter.

Concurrent load calls on the same conversation_id are serialized at the compaction seam: only one call invokes the compactor at a time; others observe the previously-stored summary and return immediately.

Constructors

new(inner : M, policy : P, compactor : C)
Source

Instance methods

append(conversation_id : String, messages : Array(Crig::Completion::Message)) : Nil
Source
clear(conversation_id : String) : Nil
Source
compactor
Source
forget(conversation_id : String) : Nil
Source
inner
Source
into_inner
Source
load(conversation_id : String) : Array(Crig::Completion::Message)
Source
policy
Source
tracked_conversations
Source