Expand description
ctx_transcript_compact business logic (#hermes-engine).
Deterministic, prompt-cache-friendly compaction of an OpenAI-format message array. Used by the Hermes context-engine plugin so the compaction lives in the daemon (Single Source of Truth) instead of being re-implemented per client (AGENTS.md #498).
Invariants (mirrored by the Python plugin’s compaction.py):
- an
assistantmessage withtool_callsis never separated from its followingtoolresults (atomic blocks); - leading / inline
system/developermessages are preserved verbatim; - output is a deterministic function of the input (no time/random).
Structs§
- Compact
Result - Outcome of a compaction pass.
Functions§
- compact_
messages - Compact a message array.
fresh_tail_tokensandprotect_min_messagesbound the verbatim tail; the split always lands on an atomic-block boundary. - render_
result - Build the JSON payload returned by the MCP tool: the compacted array plus deterministic stats. Separated so the registered wrapper stays thin.
- serialize_
transcript - Render messages to a plain-text transcript (bounded, deterministic) for durable offload into the session/knowledge store.