Skip to content

Show compaction status in CLI code agent UI#3101

Merged
youknowriad merged 1 commit intotrunkfrom
agent-context-limit
Apr 16, 2026
Merged

Show compaction status in CLI code agent UI#3101
youknowriad merged 1 commit intotrunkfrom
agent-context-limit

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

Related issues

  • Related to context window management in studio code

How AI was used in this PR

AI was used to investigate how the Claude Agent SDK handles context compaction, identify the gap in the UI layer, and write the fix.

Proposed Changes

  • Handle system message type in AiChatUI.handleMessage() — previously only assistant, user, and result were handled
  • Show a loader ("Compacting conversation history...") when the SDK begins auto-compaction
  • Show an info message ("Conversation history compacted") when compaction completes

The Claude Agent SDK automatically compacts conversation history when the context window fills up, emitting SDKStatusMessage (status: compacting) and SDKCompactBoundaryMessage (subtype: compact_boundary). These system messages were silently dropped, leaving users with an unexplained pause during long conversations.

Testing Instructions

  • Run studio code and have a long conversation that fills the context window
  • Verify that a "Compacting conversation history..." loader appears during compaction
  • Verify that a "Conversation history compacted" info message appears after

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 8e39e71 vs trunk

app-size

Metric trunk 8e39e71 Diff Change
App Size (Mac) 1282.03 MB 1282.03 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 8e39e71 Diff Change
load 1561 ms 1817 ms +256 ms 🔴 16.4%

site-startup

Metric trunk 8e39e71 Diff Change
siteCreation 8101 ms 9131 ms +1030 ms 🔴 12.7%
siteStartup 4325 ms 4950 ms +625 ms 🔴 14.5%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Contributor

@epeicher epeicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @youknowriad! I have tested it, and I can see the new statuses. Changes also LGTM!

Compacting Compacted
Image Image

@youknowriad youknowriad merged commit 9be206d into trunk Apr 16, 2026
10 checks passed
@youknowriad youknowriad deleted the agent-context-limit branch April 16, 2026 10:29
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.

3 participants