Skip to main content

Module render

Module render 

Source
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_compression fires.
build_compression_content
Build content for LLM compression.
build_messages
Context management with cold zone compression.
needs_compression
Check if context needs compression.