You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Compaction / Rolling context window #7472
Either compaction or rolling context window. Requested from Reddit user:
With a rolling context window, once the context limit of the chat is hit, the oldest top messages are trimmed off so space can be made for the newest messages, allowing the conversation to continue without needing to create a new chat.
As time goes on, the earliest parts of the conversation are forgotten but whatever hasn't been trimmed off is remembered.
I'm not sure if this is a feature already, as I wasn't able to find it in the UI.
Basically only the most recent subset of information is kept in the conversation context, while older messages are dropped to make space in the context for new messages.
In ChatGPT instead of making the user create an entire new chat, when a chat gets too long it will purposefully "forget" earlier parts of the conversation because they are dropped from the context window to make room for newer messages.
Reacted by TheAlex25, GrapeMan4, Rafael Oliveira, Antonio, zxisak and Nikunj Singh
Compaction would be cool, where the previous conversation is summarized internally into the KV cache. If that fails, then a fallback to a rolling context window.
Rolling context window and compaction both have their benefits. I like the idea of both, but if i had to choose one it would probably be the rolling context
Rolling context window preserves exact phrasing and original meaning of messages , as well as immediate task instructions without distortion.
Its also a predictable and cheap compute footprint since token size never creeps upward beyond the ceiling limit, allowing user to continue the chat without creating a new one.
Currently it seems the user can already summarize the conversation on their own and put key facts/points into a text file and attach it to the current chat to create their own pseudo compaction.
This, paired with the rolling context window would be extremely powerful for maintaining a conversation long term.
IMO: this should (must!) be fully parametric: e.g. for my use case, I need limited initial context + controlled-length sliding window + occasional compaction. Ideally would be of course vector store memory and parametric "offload"… basically thinking of a way to split the conversation into blocks and summarize and create some kind of search index that gets sent with every request so that chat history relevant to that specific request can be re-pulled-in.
Jan has already implemented this to some extend in their desktop app.
Here's some good reading about the possible approaches & architectures:
Awesome! Now I couldn't find any settings in the UI other than "Checkpoints" in "Run Settings". Any docs on this?
What I'm looking for (and built a prototype for as an intermediate pass-through server between any Client and OpenAI-compatible API) is:
The full conversation to be always sent to the LLM
"Compacted" messages to be replaced with some UIDs and stored (originals or vectors?) in cache
Decision to compact messages based on "keep first F messages", "keep last L messages", and possibly on some intermediate agent/step which suggests which other ones to keep in-between.
Tools to be made avaialable to the LLM to request the conversation again with selected (by UID) messages to be reintroduced
Controls "Keep F first", "Keep L last", "Context Length" (which might auto-adjust F/L)
I just noticed that when compaction is triggered during a tool call, output seems to be completely lost when apparently this doesn't trigger a failed tool call (I see a "output omitted: 2044 chars, no context room left" message in the CoT), that feels to be the sensible thing to happen so LLM is not tricked believing that output is accurate.
Activity
TheAlex25 commentedon Jul 26, 2026
Compaction would be cool, where the previous conversation is summarized internally into the KV cache. If that fails, then a fallback to a rolling context window.
GrapeMan4 commentedon Jul 27, 2026
Rolling context window and compaction both have their benefits. I like the idea of both, but if i had to choose one it would probably be the rolling context
Rolling context window preserves exact phrasing and original meaning of messages , as well as immediate task instructions without distortion.
Its also a predictable and cheap compute footprint since token size never creeps upward beyond the ceiling limit, allowing user to continue the chat without creating a new one.
Currently it seems the user can already summarize the conversation on their own and put key facts/points into a text file and attach it to the current chat to create their own pseudo compaction.
This, paired with the rolling context window would be extremely powerful for maintaining a conversation long term.
konradbr commentedon Aug 14, 2026
+1 on this. Let me know if I can support.
IMO: this should (must!) be fully parametric: e.g. for my use case, I need limited initial context + controlled-length sliding window + occasional compaction. Ideally would be of course vector store memory and parametric "offload"… basically thinking of a way to split the conversation into blocks and summarize and create some kind of search index that gets sent with every request so that chat history relevant to that specific request can be re-pulled-in.
Jan has already implemented this to some extend in their desktop app.
Here's some good reading about the possible approaches & architectures:
https://www.youngju.dev/blog/chatbot/2026-03-12-multiturn-conversation-management-llm-memory-context-optimization.en#full-architecture
rahulmathews commentedon Aug 15, 2026
+1 on this. I can help on this.
shimmyshimmer commentedon Aug 21, 2026
Auto compaction / rolling context window is now available.
Please update to the latest version: https://github.com/unslothai/unsloth/releases/tag/v0.1.801-beta
CC: @TheAlex25 @GrapeMan4 @konradbr @rahulmathews @Snowworm3000 @redfave @alkinun @Rafael-Silva-Oliveira @ANTONIOPSD @zxisak @nikunjsingh93
konradbr commentedon Aug 25, 2026
Awesome! Now I couldn't find any settings in the UI other than "Checkpoints" in "Run Settings". Any docs on this?
What I'm looking for (and built a prototype for as an intermediate pass-through server between any Client and OpenAI-compatible API) is:
How are the rest of you using this?
ZupoLlask commentedon Aug 26, 2026
I just noticed that when compaction is triggered during a tool call, output seems to be completely lost when apparently this doesn't trigger a failed tool call (I see a "output omitted: 2044 chars, no context room left" message in the CoT), that feels to be the sensible thing to happen so LLM is not tricked believing that output is accurate.
Can someone confirms this behavior, please?
konradbr commentedon Sep 5, 2026
@ZupoLlask I can confirm the "output ommited" behaviour happens quite frequently, indeed!