feat(compression): make protect_first_n configurable

The number of head messages preserved verbatim across context compactions
was previously hardcoded to 3 in AIAgent.__init__. Expose it as
compression.protect_first_n in config, matching the existing
protect_last_n pattern.

Motivation: users who rely on rolling compaction for long-running
sessions had the opening user/assistant exchange pinned as head
forever, which doesn't always match how they want the session framed
after many compactions. Lowering to 1 preserves only the system
prompt and lets the first exchange age out naturally through the
summary.

- hermes_cli/config.py: add default (3) + show_config() line
- run_agent.py: read from config with max(1, ...) floor so the
  system prompt always survives head-protection
- cli-config.yaml.example: document with rationale
- tests/agent/test_context_compressor.py: cover default, override,
  and end-to-end behavior when protect_first_n=1
- scripts/release.py: add simpolism@gmail.com to AUTHOR_MAP
This commit is contained in:
simpolism 2026-04-21 21:13:47 -04:00
parent 83a7a005aa
commit 46b75960ed
5 changed files with 67 additions and 1 deletions

View file

@ -323,6 +323,16 @@ compression:
# compression of older turns.
protect_last_n: 20
# Number of earliest messages to always preserve verbatim as head (default: 3 =
# system prompt + first user/assistant exchange). Head messages are NEVER
# summarized — they survive every compression indefinitely. This gives stable
# early context for short/medium sessions, but in long-running sessions that
# rely on rolling compaction the opening user turn gets pinned forever, which
# may not match how you want the session framed. Lower to 1 to preserve only
# the system prompt and let the first exchange age out naturally through the
# summary. Minimum: 1 (system prompt must survive).
protect_first_n: 3
# To pin a specific model/provider for compression summaries, use the
# auxiliary section below (auxiliary.compression.provider / model).