Class ContextWindowGarbageCollector
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.context.ContextWindowGarbageCollector
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
Orchestrates the monitoring and logging of the Context Window Garbage
Collection (CwGC). This class calculates high-fidelity metrics for prompt
load and recycling efficiency using a one-pass calculation strategy.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData object containing the categorized token metrics. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ContextManagerThe parent ContextManager orchestrating the active session.private final List<GarbageCollectorRecord> The concurrent log records of all garbage collection sweeps.The results of the last token calculation pass.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupportModifier and TypeFieldDescriptionprotected PropertyChangeSupportSupport for firing property change events. -
Constructor Summary
ConstructorsConstructorDescriptionContextWindowGarbageCollector(@NonNull ContextManager contextManager) Constructs a ContextWindowGarbageCollector with its parent manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms a comprehensive, one-pass calculation of all token metrics in the current context.voidclearLog()Clears the collection logs.Gets an unmodifiable view of the collection log.voidrecordCollection(@NonNull AbstractMessage message) Records the recycling of a message turn.private StringsummarizeParts(AbstractMessage message) Generates a compact parts summary string for a message being garbage collected.Methods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerModifier and TypeMethodDescriptionvoidAdds a property change listener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a property change listener for a specific property.voidrebind()Re-initializes the transientPropertyChangeSupportafter deserialization.voidRemoves a property change listener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes a property change listener for a specific property.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupportModifier and TypeMethodDescriptionGets the PropertyChangeSupport instance for this object.
-
Field Details
-
contextManager
The parent ContextManager orchestrating the active session. -
logRecords
The concurrent log records of all garbage collection sweeps. -
stats
The results of the last token calculation pass.
-
-
Constructor Details
-
ContextWindowGarbageCollector
Constructs a ContextWindowGarbageCollector with its parent manager.- Parameters:
contextManager- The parent ContextManager instance.
-
-
Method Details
-
calculate
public void calculate()Performs a comprehensive, one-pass calculation of all token metrics in the current context. This categorizes tokens into system instructions, tools, metadata, and various history states using the active session tokenizer. -
summarizeParts
Generates a compact parts summary string for a message being garbage collected.- Parameters:
message- The message to summarize.- Returns:
- The formatted summary string.
-
recordCollection
Records the recycling of a message turn.- Parameters:
message- The message being garbage collected.
-
clearLog
public void clearLog()Clears the collection logs. -
getRecords
Gets an unmodifiable view of the collection log.- Returns:
- The list of collection records.
-

