Wardrik. Compaction
(wardrik v0.1.0-rc.1)
Copy Markdown
Middleware that summarises an agent's older history when a turn starts.
It runs once the history passes :at of the model's context window. The most recent :keep
of the window stays word for word.
Options
:at- the share of the window that triggers compaction.0.6unless set.:keep- the share of the window kept word for word.0.25unless set.:window- the window in tokens, if the model catalog has none.128_000unless set.
Behaviour
- The agent's own model writes the summary, in a
compactionstep. Policy and budgets apply as for any model call. - History is only cut where a person's message starts.
- Resumed turns aren't compacted.
- The summary keeps the labels of what it replaces, such as
"outside". - If summarising fails, the history is left as it is and the turn runs anyway.
- Each compaction emits
[:wardrik, :conversation, :compacted]with message and token counts before and after.