Repository navigation
feat(chat): /clear and /compact commands, and early compaction near the context limit - #269
Merged
Merged
Conversation
…he context limit Typed in the web chat or a chat room, /clear makes the assistant start afresh and /compact [what to keep] folds the conversation into its summary now. A conversation that fills half the model's context (ai.context_tokens) is summarised before the next answer, and ai.compact_model lets a cheaper model write the summaries. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GfeBnnG9GVGeacqW6FCcpb
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
65DA
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: long conversations were folded into a running summary only after every 8 messages. There was no way to reset or summarise a conversation yourself, and a few long messages could overflow a small model's context before that count was reached.
After:
/clear, typed in the web chat or a chat room (Lens /clear), makes the assistant start afresh. The messages stay visible, but the model no longer reads them./compact [what to keep]folds the whole conversation into its summary now and shows that summary as the reply.ai.context_tokens, 16000 when empty) is summarised before the next answer.ai.compact_model) lets a smaller, cheaper model write the summaries.How: the summary's
uptomarker now also records a clear.chat.command/chat.run_commandhandle both commands, and the chats route and the bridge call them before any model call. The streams sendcleared/compacted, then the reply as an ordinary answer.Motivation and Context
Adeel asked for the assistant chat to auto-compact, and for users to be able to
/clearand/compact.Types of changes
Checklist:
docs/(assistant.md, chat-rooms.md).🤖 Generated with Claude Code
https://claude.ai/code/session_01GfeBnnG9GVGeacqW6FCcpb
Generated by Claude Code