Skip to content

FoundryHarnessHybridCompactionOptions

NexusLabs.Foundry.MicrosoftAgentFramework.Harness.Bundle

FoundryHarnessHybridCompactionOptions Class

The explicit configuration for Foundry's per-provider-call hybrid compaction, which bounds what is \<em>sent\</em> on each individual provider request rather than what the agent remembers.

public sealed record FoundryHarnessHybridCompactionOptions : System.IEquatable<NexusLabs.Foundry.MicrosoftAgentFramework.Harness.Bundle.FoundryHarnessHybridCompactionOptions>

Inheritance System.Object 🡒 FoundryHarnessHybridCompactionOptions

Implements System.IEquatable<FoundryHarnessHybridCompactionOptions>

Remarks

Where this acts. Foundry wraps the configured chat client at the innermost position, beneath everything the bundle installs above it. Both the function-invocation loop and message injection call their inner client afresh for each round, so every intermediate tool round cascades down and is bounded — including the round carrying a tool call and its result, which upstream's per-turn compaction never observes. See HybridCompaction and Compaction for how the two dimensions differ.

Sizes are UTF-8 bytes of rendered message content, not provider tokens. Bytes are used because they are computable locally and deterministically without a tokenizer that matches the specific provider; pick a budget with headroom rather than treating it as a token count.

Reductions bound one dispatch, not stored history. This node is inner to the per-service-call history decorator, so history is persisted before a reduction is applied and every call re-assembles from the full record. Nothing is permanently discarded, and the work is not cumulative.

Properties

FoundryHarnessHybridCompactionOptions.HardLimitBytes Property

Gets the absolute ceiling, in UTF-8 bytes, for the assembled context of a single provider call. A call whose context cannot be reduced below this fails rather than being forwarded.

public int HardLimitBytes { get; init; }

Property Value

System.Int32

FoundryHarnessHybridCompactionOptions.MaximumCompactionAttempts Property

Gets how many reduction attempts may run for one provider call before the context is declared irreducible and the call fails. More than one attempt can be needed because a concurrent injection can invalidate an in-flight proposal, which is discarded and restarted from the newest snapshot.

public int MaximumCompactionAttempts { get; init; }

Property Value

System.Int32

FoundryHarnessHybridCompactionOptions.RecentMessageRetentionCount Property

Gets how many of the most recent messages are always preserved and never reduced away.

public int RecentMessageRetentionCount { get; init; }

Property Value

System.Int32

FoundryHarnessHybridCompactionOptions.TriggerMarginBytes Property

Gets the margin, in UTF-8 bytes, below HardLimitBytes at which compaction begins. Compaction triggers once assembled context exceeds HardLimitBytes - TriggerMarginBytes. Must be strictly less than HardLimitBytes, so that a positive trigger threshold exists.

public int TriggerMarginBytes { get; init; }

Property Value

System.Int32

FoundryHarnessHybridCompactionOptions.UpstreamReducer Property

Gets the reducer whose output is treated as a compaction \<em>proposal\</em>, never as ground truth: Foundry verifies it against HardLimitBytes and its own structural-preservation rules before anything is dispatched, and fails the request rather than forwarding an over-budget or structurally invalid context.

public Microsoft.Extensions.AI.IChatReducer UpstreamReducer { get; init; }

Property Value

Microsoft.Extensions.AI.IChatReducer

Remarks

Upstream's CompactionStrategy implementations are not usable here. They operate on upstream's per-turn message index; this seam reduces the messages of a single provider request and therefore takes an Microsoft.Extensions.AI.IChatReducer.