Context and History Compaction
FabrCore 2.0 · Release and package availability
These guides track the current 2.0 source. Stable 2.0.0 publication is pending; package commands show the release target. Until it is published, follow the source quick start or use a matching available prerelease set. Release migration · Runtime modes
Working context and stored history have different jobs
FabrCore 2.0 checks context before every model call inside the tool loop, while separately creating validated handovers for older conversation history. Both work without long-term Memory or SQL.
| Layer | When | What changes |
|---|---|---|
| Working context | Before each model call, including tool loops | Older tool results become bounded excerpts; original history is retained |
| Durable history | Between turns | Validated summarization replaces older interaction groups in stored history |
| Projection and run safety | At budget boundaries | Stops work when protected content cannot fit |
Configure the input working set
Set both ContextWindowTokens and MaxOutputTokens. Missing metadata produces context:unconfigured. Optional ContextWorkingSetTokens reduces input context, capped by the physical window minus output reservation.
{
"ContextWindowTokens": 128000,
"MaxOutputTokens": 16384,
"ContextWorkingSetTokens": 64000,
"ContextCompactionEnabled": true,
"ContextEvictThreshold": 0.5,
"ContextTruncateThreshold": 0.8,
"CompactionEnabled": true
}These fields belong on a model entry in ModelConfigurations. Agent overrides include _ContextWorkingSetTokens, _ContextCompactionEnabled and _CompactionThreshold.
Older tool results keep a bounded head and tail: 2,048 characters at 50% of the working set, tightening to 512 at 80%. User text, instructions, assistant prose, handovers and the latest two interaction groups are protected. Tool-call/result pairs and identifiers stay together. Thresholds are soft targets; protected oversized content can stop a run.
Save history only after validation
Automatic durable compaction uses 70% of a usable input working set, with a 75% fallback when context configuration is unavailable. The old 87% default no longer applies. Explicit thresholds still override defaults. These are separate lifecycle controls, not five strictly ordered execution steps.
Summarization requires model context metadata, reserves output and headroom, and processes complete interaction groups. Reduction is bounded to eight passes and 64 model calls with no-progress detection. Select a separate summarizer with _CompactionModelConfigName or CompactionConfig.SummaryModelConfigurationName.
A single validated write preserves instructions, the latest user message and the latest interaction group. Empty, incomplete, canceled, length-limited, oversized, malformed-tool, nonreducing or stale concurrent results leave original history intact. Handovers use assistant context; legacy system-authority handovers are demoted on read. Summaries do not guarantee semantic fidelity.
Diagnostics and harness behavior
The resolved diagnostic reports tool-excerpt, tool-excerpt-tight, history, fuse and stop thresholds. Transient compaction indices reset per history invocation and are excluded from snapshots. Monitor events report history compaction start, completion and failure.
Use FabrCoreHarnessResult.RunAsync for harness snapshot persistence. Background waits default to 300 seconds via _HarnessBackgroundWaitTimeoutSeconds. Memory-aware extraction/compaction remains an explicit opt-in integration.
MidTurnCompactionEnabled and its agent override are retired and ignored. Run safety no longer rewrites history mid-turn or exposes checkpoint counts. See the 2.0 upgrade guide.