8000 feat(chat): /clear and /compact commands, and early compaction near the context limit by adeelahmad · Pull Request #269 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(chat): /clear and /compact commands, and early compaction near the context limit - #269

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-hixzs2
Oct 10, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-hixzs2

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

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.
  • A conversation that fills half the model's context (Chat model's context, ai.context_tokens, 16000 when empty) is summarised before the next answer.
  • Model for summaries (ai.compact_model) lets a smaller, cheaper model write the summaries.
  • The commands still work when automatic summaries are turned off. The model never reads the commands or their replies.

How: the summary's upto marker now also records a clear. chat.command/chat.run_command handle both commands, and the chats route and the bridge call them before any model call. The streams send cleared/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 /clear and /compact.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project.
  • I added or updated tests (test_compaction.py, test_bridge.py; the full backend suite passes locally).
  • I updated docs/ (assistant.md, chat-rooms.md).
  • CHANGELOG entry (the title covers it).

🤖 Generated with Claude Code

https://claude.ai/code/session_01GfeBnnG9GVGeacqW6FCcpb


Generated by Claude Code

…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
@adeelahmad adeelahmad self-assigned this Oct 10, 2026
@adeelahmad
adeelahmad merged commit 5278ff2 into main Oct 10, 2026
7 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-hixzs2 branch October 10, 2026 20:10
Sign up for free 65DA to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0