Skip to content

CompactionSettings

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

Determines how an agent compacts its conversation history.

public sealed record CompactionSettings : IEquatable<CompactionSettings>

objectCompactionSettings

IEquatable<CompactionSettings>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

When left null no compaction is applied, and the run fails once the conversation history no longer fits the model context window. An invalid combination of fields (for example choosing CompactionStrategyKind.Summarization without any trigger) is rejected while the agent is built, with AgentPrismCompilationException; it is not ignored silently.

public CompactionSettings()

Gets the context window size. It is required for CompactionStrategyKind.ContextWindow and ignored by the other strategies.

public int? MaxContextWindowTokens { get; init; }

int?

Gets the upper output token limit for CompactionStrategyKind.ContextWindow. When it is not given, ModelBinding.MaxOutputTokens from the agent’s own model binding is used, and 4096 when that is missing too.

public int? MaxOutputTokens { get; init; }

int?

Gets the minimum number of groups kept for CompactionStrategyKind.Truncation, CompactionStrategyKind.ToolResult and CompactionStrategyKind.Summarization. 4 is used when it is not given.

public int? MinimumPreservedGroups { get; init; }

int?

Gets the minimum number of turns kept for CompactionStrategyKind.SlidingWindow. 2 is used when it is not given.

public int? MinimumPreservedTurns { get; init; }

int?

Gets the strategy to apply.

public CompactionStrategyKind Strategy { get; init; }

CompactionStrategyKind

Gets the model used for the summarization call. When it is empty the order is followed: the application-wide helper model setting, and the agent’s own model when that is missing.

public ModelBinding? SummarizationModel { get; init; }

ModelBinding?

Gets the extra instruction added to the summarization prompt for CompactionStrategyKind.Summarization and CompactionStrategyKind.Pipeline. When null the default prompt of MAF is used.

public string? SummarizationPrompt { get; init; }

string?

Gets the message count above which compaction is triggered.

public int? TriggerMessages { get; init; }

int?

Gets the token count above which compaction is triggered.

public int? TriggerTokens { get; init; }

int?

Gets the turn count above which compaction is triggered.

public int? TriggerTurns { get; init; }

int?

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(CompactionSettings? other)

other CompactionSettings?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(CompactionSettings?, CompactionSettings?)

Section titled “ operator ==(CompactionSettings?, CompactionSettings?)”
public static bool operator ==(CompactionSettings? left, CompactionSettings? right)

left CompactionSettings?

right CompactionSettings?

bool

operator !=(CompactionSettings?, CompactionSettings?)

Section titled “ operator !=(CompactionSettings?, CompactionSettings?)”
public static bool operator !=(CompactionSettings? left, CompactionSettings? right)

left CompactionSettings?

right CompactionSettings?

bool