Class History
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
This toolkit is primarily used during 'History Compression' turns where the model is forced to evaluate its own context window and decide which information remains relevant.
- Author:
- anahata
-
Field Summary
Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClears all Context Window Garbage Collector (CwGC) log records from memory.Creates the consolidated history index.Gets a list of system instruction strings provided by this context provider.voidpopulateMessage(RagMessage ragMessage) Populates the RAG message with comprehensive session metadata.setInjectInbandMetadata(boolean enabled) Toggles the injection of in-band metadata headers.setMessagePruningState(List<Long> messageIds, PruningState newState) Updates the pruning policy for all parts of one or more messages.setPartPruningState(List<Long> partIds, PruningState newState) Updates the pruning policy for specific message parts.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, initialize, isEffectivelyProviding, postActivate, rebindMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, isProviding, setParentProvider, setProviding
-
Constructor Details
-
History
public History()
-
-
Method Details
-
getSystemInstructions
Gets a list of system instruction strings provided by this context provider. These are typically prepended to the conversation as high-level guidance.Provides context-aware system instructions for the History toolkit, detailing CwGC operational parameters, pruningStates, and metadata strategies.
- Returns:
- A singleton list containing the detailed history system prompt.
- Throws:
Exception- if metadata serialization or context lookup fails.
-
populateMessage
Populates the RAG message with comprehensive session metadata.Provides a Markdown summary of session identity, model configuration, context window usage, and the status of executing tools.
- Parameters:
ragMessage- The target RAG message.- Throws:
Exception- if metadata extraction fails.
-
createConsolidatedIndex
Creates the consolidated history index.- Returns:
- The formatted Markdown consolidated index string containing message and part metadata.
-
clearGarbageCollectorLogs
Clears all Context Window Garbage Collector (CwGC) log records from memory.- Returns:
- A descriptive confirmation string indicating the number of logs cleared.
-
setMessagePruningState
Updates the pruning policy for all parts of one or more messages.Pruning states:
- PINNED: Never garbage collected; always remains in context.
- PRUNED: Excluded from the next API payload but kept in history.
- AUTO: Standard lifecycle managed by the CwGC system.
- Parameters:
messageIds- The sequential IDs of the messages to update.newState- The new pruning state to apply.- Returns:
- Confirmation message.
-
setPartPruningState
Updates the pruning policy for specific message parts.This tool allows for granular control over individual content segments, such as pinning a critical code block while allowing the rest of the message to be pruned.
- Parameters:
partIds- The sequential IDs of the parts to update.newState- The new pruning state.- Returns:
- Confirmation message.
-
setInjectInbandMetadata
Toggles the injection of in-band metadata headers.When enabled, the model receives unique sequential IDs for every message and part in the history, enabling the use of pruning tools.
- Parameters:
enabled- If true, metadata headers are included in the prompt.- Returns:
- Confirmation message.
-

