If you've run a long agent session in any framework, you've hit the wall: context fills up, the framework decides it's time to compact, and everything stops while a summarizer chews through the whole transcript. In hermes-agent that batch compaction fires around 80% of the context threshold, and on a long session the pause is measured in minutes. The agent isn't stuck, it's doing necessary work, but from the outside it looks dead. And the longer you wait to compact, the bigger the lump you eventually pay.

Micro-compaction is a different way to pay the same bill. Instead of one big batch pass when you're nearly full, you fold the oldest un-absorbed exchange into a rolling summary after every turn. The total summarization work is roughly the same. What changes is the shape of the cost: small increments spread across the session instead of one long stall at the worst possible moment.

Origin note, since it's unusual: the first draft of this feature was written by Hermes itself, for its own codebase. What follows, the measurement, the bugs, and the upstreaming, is what it took to get that draft into a state worth merging.

How it works

After each turn, the finalizer looks for the oldest agent turn that hasn't been absorbed yet, summarizes it into a cumulative rolling summary, and splices a single summary marker into the transcript where that material used to be. There's exactly one marker at any time. Each pass replaces it rather than adding another. A protected head (the system prompt and early setup) and a protected tail (the most recent turns, 16% of the window by default) never get touched, so the model always has verbatim access to what it's currently working on.