Skip to content

Studio: show the compaction count in the context meter - #13355

Merged
danielhanchen merged 8 commits into
unslothai:mainfrom
danielhanchen:pr12759-compaction-count-fixes
Oct 12, 2026
Merged

danielhanchen merged 8 commits into
unslothai:mainfrom
danielhanchen:pr12759-compaction-count-fixes

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #12625. Supersedes #12759 by @Yudeeswaran (their commits are kept here; that branch conflicts with main and is not open to maintainer edits).

Problem

Long chats compact themselves automatically. The only trace is the "Context compacted" notice in the transcript, which is easy to scroll past in a long session, so there is no way to tell at a glance how many times a chat has been compacted (and so when it is time to start a fresh one).

Change

  • The context meter tooltip in the chat header gains a Compactions N row.
  • N is compactionNoticeMessageIds(thread.messages).size: the same memoized set the transcript uses to decide which assistant messages render the "Context compacted" notice, so the count always equals the notices on screen (active branch, checkpoint starts included, a boundary that moves backwards not re-counted).
  • CompactionCountRegistrar publishes the count from inside the assistant-ui runtime (the header sits outside it); ChatPage keeps it keyed by thread id, so a thread switch never shows another chat's count. It is mounted for single-chat and project views, so a chat started from a project landing page is counted too.
  • The row only appears once a chat has compacted at least once; the tooltip is unchanged for every chat that never compacts.

Testing

  • tsc -b clean; full frontend suite passes (11325 tests).
  • Live, real llama-server: Qwen3.5-0.8B GGUF at a 2,048 window, three turns produce two compaction notices on both builds; the tooltip shows the count only on this branch (screenshot below).

Before / after

Qwen3.5-0.8B GGUF (UD-Q4_K_XL) at a 2,048 token window, Max Tokens 256, temperature 0. Three turns produce two "Context compacted" notices on both builds, then the header meter is hovered. Before = merge base fcee6485f, after = this PR at 40d563cd7.

The tooltip gains a Compactions 2 row, matching the two notices in the transcript; nothing else in it moves.

Context meter tooltip before and after two automatic compactions

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T02:59:45.462618Z 40d563c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 40d563cd73

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free 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.

[Feature] Unsloth Studio Context Length meter #2: Add a count for automatic compactions.

2 participants