Third pipeline stage — collapses runs of repetitive tool calls.
When a model issues several similar tool calls in a row (think:
three consecutive Reads of related files, four Globs for a
refactor sweep), each result message contributes meaningfully but
collectively wastes context. Microcompact replaces a run of three
or more adjacent same-tool tool-result messages with a single
elided summary that lists the calls and trims each result body.
Pure-Elixir, no LLM call. Deterministic — same input always produces same output. Idempotent: a run already reduced to a single micro-summary is left alone (it's no longer a run of tool calls).
Heuristic for "same tool":
- adjacent tool-role messages
- each is the result of a single tool call (one entry in
tool_results) - matching tool names on the assistant's parent
tool_calls