<!-- @aparte/plugin-compaction writes contextSummary on the first turn it keeps; the bubble
draws the separator from it, and the turns above stay on screen. -->
<aparte-chat-viewport style="height: 24rem"></aparte-chat-viewport>
<script>
document.querySelector('aparte-chat-viewport').setMessages([
{ id: 'u1', role: 'user', content: 'How do I export my data?', timestamp: Date.now() },
{ id: 'a1', role: 'assistant', content: 'Open Settings, then Data, and choose Export. You get a ZIP of your conversations and files.', timestamp: Date.now() },
{
id: 'u2', role: 'user', content: 'Can I schedule it every week?', timestamp: Date.now(),
contextSummary: {
summary: 'The user asked how to export their data; the assistant explained Settings, then Data, then Export, which produces a ZIP of conversations and files.',
count: 2,
createdAt: Date.now(),
},
},
{ id: 'a2', role: 'assistant', content: 'Yes: under Export, turn on Weekly export and pick the day.', timestamp: Date.now() },
]);
</script>A conversation can outgrow the model’s context window. @aparte/plugin-compaction then asks the model
to summarise the older turns, and the model reads that summary in their place from then on. The turns
themselves stay where they are, for the person to read: the separator marks the first turn the model
still reads word for word.
It sits above that turn’s message, centred, outside the bubble, and says how many messages the summary stands for. Show summary unfolds what the model reads instead of them. Restore asks first, then sends the original messages to the model again, every summary of the conversation included.
States
Section titled “States”- Summarising: “Summarising the context…”, while the summary is written.
- Done: the count, Show summary and Restore.
- Failed: what went wrong, and Retry. Nothing was removed, so the conversation goes on as it was.
A conversation compacted before 0.26, whose summary replaced its first turns, shows the same separator without a count and without Restore: its original messages are no longer there to restore.
import { setupCompaction } from '@aparte/plugin-compaction';
setupCompaction(); // the global config, the current model's windowThe separator is drawn by the message bubble from the message’s contextSummary, which the plugin
writes on the first turn it keeps, so it needs no markup and is saved with the conversation. When to
compact, how much to keep and how the summary is written are on
Long conversations.
Customize
Section titled “Customize”The separator is .aparte-checkpoint inside the bubble; its actions wear the
button recipe, and its text and rules follow the muted text and border tokens.
A bubble you draw yourself draws the separator from message.contextSummary.
Accessibility
Section titled “Accessibility”- The separator is a group named by the
checkpointGroupkey (“Context summary”), read before the message it precedes; Show summary is a disclosure button witharia-expanded. - Restore asks in place, and the keyboard stays in the transcript once the separator is gone.
Related
Section titled “Related”- Context gauge — how full the window is, and Compact now.
- Message — the bubble it is drawn in.