context_compaction

command
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 8 Imported by: 0

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/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL