Compaction notice
The summary that takes the place of the oldest turns when a long conversation fills the model's context, so the conversation can go on.
On this page
<!-- @aparte/plugin-compaction writes this message when the context fills up; any message
with compaction: true is drawn the same way. -->
<aparte-chat-viewport style="height: 24rem"></aparte-chat-viewport>
<script>
// A restored conversation: the summary, then the reply that was kept as it was.
document.querySelector('aparte-chat-viewport').setMessages([
{
id: 'c1', role: 'user', compaction: true, timestamp: Date.now(),
content: '**Conversation summary**\n\nThe user is preparing release 0.19.2: two CSS fixes (the sidebar drawer, the menu check mark) and gzip on the docs server. The changelog is written; the tag is not pushed yet.',
},
{ id: 'a9', role: 'assistant', content: 'The changelog is in. What is left: wait for CI on the release commit, then push the tag alone.', timestamp: Date.now() },
]);
</script>A conversation can outgrow the model’s context window. Rather than failing, or silently dropping
the start, @aparte/plugin-compaction asks the model to summarise the oldest turns and puts that
summary in their place, keeping the recent turns as they were. The summary is shown as a notice:
centred, with a dashed border, and no avatar, name, time or actions, because nobody said it.
The notice is a message with compaction: true. Its title comes from the compactionSummaryTitle
locale key (“Conversation summary”). It is sent to the model as context from the user, introduced
as a summary, since some providers refuse a system message in the middle of a conversation.
import { setupCompaction } from '@aparte/plugin-compaction';
setupCompaction(); // the global config, the current model's window<aparte-composer-toolbar>
<aparte-context variant="ring" auto-compact></aparte-context>
</aparte-composer-toolbar>With the context gauge’s auto-compact, compaction starts when the
gauge reaches danger; the plugin can also be called on demand. How much it keeps, how it
summarises and the events it fires are on Long conversations.
A conversation you restore keeps its notice like any other message: compaction: true is part of
the message, so it is saved and drawn the same way.
Customize
Section titled “Customize”The notice is the message’s bubble with data-kind="compaction", so a selector on
aparte-chat-bubble[data-kind="compaction"] restyles it. Its text is the summary, rendered as
Markdown when a renderer is installed.
Accessibility
Section titled “Accessibility”- The notice is a message like the others in the transcript, read in order; its title says what it is before the summary.
Related
Section titled “Related”- Context gauge — what triggers it.
- Message — the bubble it is drawn in.