Documentation
¶
Overview ¶
Example: context_compaction demonstrates automatic context compaction (WC-A-004). As a session conversation grows toward the model's context window, Chronos summarizes older turns into a compact running summary and keeps only the most recent turns — so a long conversation continues coherently instead of overflowing or being hard-truncated.
Two things are ALWAYS retained through every compaction pass:
- a static pinned contract (ContextConfig.PinnedMessages), and
- a dynamic pin (WithContextPins) — here a live "active plan" — which is re-evaluated every turn.
A small deterministic mock model.Provider drives the loop, so the example runs with NO API keys and NO network access. The mock recognises the summarizer's own request and returns a short rolled-up summary for it; every other call returns a normal answer. A hook prints when compaction fires and how many messages were preserved.
go run ./examples/context_compaction/