Expand description
Default render & compression-plan policy for atomcode ctx.
build_messages, needs_compression, and
build_compression_content implement the out-of-the-box context
behavior. DefaultCtx is a thin wrapper over them; OllamaCtx
reuses build_messages / build_compression_content and overrides
only the compression threshold (early trigger).
Implementations wanting different behavior (different thresholds,
different compression content format, different cold-zone layout)
write their own impl CtxBuilder without touching this module.
All functions here are free functions taking &Conversation,
keeping Conversation as a pure data container — no render logic
leaks back into the data layer.
Constants§
- AUTO_
COMPACT_ BUFFER_ LARGE - Reserved headroom for large windows (CC / Anthropic 200K territory)
where compaction can afford to leave a generous response + tool-result
runway. Mirrors CC’s
AUTOCOMPACT_BUFFER_TOKENS. - AUTO_
COMPACT_ BUFFER_ SMALL - Reserved headroom for small/proxy-bound windows (typical self-hosted GLM 65K). 5K leaves space for one streaming response + a round of tool results without forcing compaction so early it shrinks the usable session. Larger buffers (13K) on a 65K cap kick compaction at 52K — wasting the 12K immediately above where users do real work.
- AUTO_
COMPACT_ LARGE_ WINDOW_ FROM - Cutoff between “small” and “large” windows. 100K is the natural dividing line: anything ≤ 100K is a self-hosted / proxy-bound deployment that benefits from a tight buffer; anything > 100K is a vendor offering (Anthropic 200K, etc.) where the wider buffer matches CC’s behaviour.
Functions§
- auto_
compact_ threshold - Compute the auto-compression trigger threshold for a given context
window. Returns the token total above which
needs_compressionfires. - build_
compression_ content - Build content for LLM compression.
- build_
messages - Context management with cold zone compression.
- needs_
compression - Check if context needs compression.