Extend the sc#397 compactor (crates/aien-cli/src/compaction.rs) with the parts Hermes has and we lack. Hermes source: website/docs/developer-guide/micro-compaction.md, agent/usage_anchor.py, agent/conversation_compression.py.
Mechanics to implement:
- The operator's own messages are never summarized; only the agent's derived material (tool results, narration) is compacted. Head (system prompt, opening messages) and a token-budgeted tail stay verbatim.
- One exchange (one assistant turn with its tool results) absorbed per turn into a single rolling summary, so cost per turn is bounded. Opt-in, because each pass changes the prompt prefix.
- The transcript is the source of truth for the cursor: a resumed process finds the last summary marker and continues after it; nothing is summarized twice.
- Only the newest summary marker is kept; past 2,000 tokens the summary itself is re-summarized (defrag) without touching messages.
- The store step is an atomic archive-and-insert so a resume never loads both the summary and the rows it replaced. Keep sc#397's durable originals with digests (Hermes lacks that; we keep it).
- A failing exchange is skipped after three failures; a persisted cooldown ladder (60 s, 300 s, 900 s) paces summarizer failures; a deterministic fallback summary route exists.
- Token accounting anchored on the provider's reported prompt and completion counts, keyed by a content fingerprint and persisted with the session; local estimates cover only appended messages. An estimate over threshold is not proof a request will fail: wait one request for provider evidence.
Acceptance: a test transcript where the operator's lines survive byte-identical through 50 compaction passes; resume after kill does not double-load; one bad exchange cannot stall every turn; an estimate above the window alone never triggers compaction.
Parent: aien-dev/aien-architecture#267. Research note: aien-architecture docs/research/hermes-agent-prior-art.md. Prior art: Hermes Agent, Nous Research, MIT, commit 5480918 (2026-10-18). No Hermes code is copied; the mechanism is re-implemented from reading. The module header credits Hermes Agent, Nous Research, the MIT licence and the commit. Rust now, pure part effect-free and content-addressed so it can move to Omega (ADR 0024). No Python.
🤖 Generated with Claude Code