Configurable compaction strategy tuned for a persistent companion agent (relational history, not disposable coding scaffolding).
config (context.*) #
compaction_strategy: companion | context-full | snapcompact | remote | off (default companion)deep_archive(default true) — layer-3 togglejournal_before_compaction(default true) — layer-1 toggleremote_compaction { endpoint, model, streaming_endpoint }— OpenAI provider-native seam for a future gpt-5.6 / terra swap
companion pipeline (3 layers, at the trigger) #
- journal-first — the same-model summary that replaces the middle history is also appended to the durable indexed journal, so the ephemeral in-context summary need not carry the whole emotional load
- same-model directed summary —
configuredSummaryProvider(preferActiveModel)forces the head that generated the conversation (only way to salvage lessons from a provider that hides its CoT); accepts a one-time cache bust at the cliff instead of letting preserve_prompt_cache silently disable all compaction - deep archive — pluggable DeepArchiveBackend: OpenAiRemoteArchive (config endpoint), TextAppendixArchive (Anthropic/default collapsed raw block), SnapcompactFramesArchive (stub until oh-my-pi's native renderer is vendored — follow-up)
loop.ts gets a single applyCompaction() dispatcher; snapcompact degrades to context-full until frames exist; companion defers proactive tool-result nibbling to the one decisive cliff-defense burn to protect cache.
Designed to defend the 200k price cliff (paired nix change sets compact_trigger_tokens=200000, strategy=companion).
verification #
- typecheck clean
- 77/77 niri-runtime tests pass (7 new: deep-archive backends + strategy enum)