Add conversation history compaction start event and enhance compaction metrics - #1768
Conversation
…statistics - Add `conversation_history_compaction_start` event emitted before compaction begins, so HTTP clients can show a loading state - Enhance `conversation_history_compacted` end event with detailed statistics: compression ratio, message counts before/after, context window info, and compaction LLM call cost breakdown - Document both events in the HTTP API reference with full payload schemas - Update event flow example to include the new start event https://claude.ai/code/session_01Pmypw4hEkVU9pXgdd6j8Hq Signed-off-by: Claude <noreply@anthropic.com>
Include the full LLM-generated conversation summary in the compaction end event so HTTP clients can inspect what context was preserved and debug compaction quality. https://claude.ai/code/session_01Pmypw4hEkVU9pXgdd6j8Hq Signed-off-by: Claude <noreply@anthropic.com>
Claude Code ReviewThis repository is configured for manual code reviews. Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdded instrumentation for conversation history compaction: a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Limiter as InputContextWindowLimiter
participant Events as Stream/EventEmitter
participant LLM as LLM/Compaction
participant Output as Client Stream
Client->>Limiter: limit_input_context_window(messages, tokens)
Note over Limiter: Determine if compaction needed
Limiter->>Events: emit(conversation_history_compaction_start {initial_tokens, num_messages, max_context_size, threshold_pct})
Events->>Output: conversation_history_compaction_start
Limiter->>LLM: request compaction (history)
LLM-->>Limiter: compaction_text + usage (tokens)
Note over Limiter: compute compression_ratio_pct, num_messages_before/after, compaction_summary, compaction_cost
Limiter->>Events: emit(conversation_history_compacted {compaction_summary, content, metadata: compaction_stats})
Events->>Output: conversation_history_compacted
Limiter->>Events: emit(ai_message (compaction notice))
Events->>Output: ai_message
Limiter-->>Client: return updated/compacted messages
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Docker images ready for
Use these tags to pull the images for testing. 📋 Copy commandsgcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:0a744ada
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:0a744ada me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:0a744ada
docker push me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:0a744ada
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes-operator:0a744ada
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes-operator:0a744ada me-west1-docker.pkg.dev/robusta-development/development/holmes-operator-dev:0a744ada
docker push me-west1-docker.pkg.dev/robusta-development/development/holmes-operator-dev:0a744adaPatch Helm values in one line (choose the chart you use): HolmesGPT chart: helm upgrade --install holmesgpt ./helm/holmes \
--set registry=me-west1-docker.pkg.dev/robusta-development/development \
--set image=holmes-dev:0a744ada \
--set operator.registry=me-west1-docker.pkg.dev/robusta-development/development \
--set operator.image=holmes-operator-dev:0a744adaRobusta wrapper chart: helm upgrade --install robusta robusta/robusta \
--reuse-values \
--set holmes.registry=me-west1-docker.pkg.dev/robusta-development/development \
--set holmes.image=holmes-dev:0a744ada \
--set holmes.operator.registry=me-west1-docker.pkg.dev/robusta-development/development \
--set holmes.operator.image=holmes-operator-dev:0a744ada |
The continuation marker is an internal detail of how compaction works, not something HTTP clients need to know about. https://claude.ai/code/session_01Pmypw4hEkVU9pXgdd6j8Hq Signed-off-by: Claude <noreply@anthropic.com>
294496f
into
claude/refactor-tool-calling-streaming-thzaD
Summary
Enhanced the conversation history compaction feature by adding a new
conversation_history_compaction_startevent and significantly expanding the metadata and diagnostics provided in theconversation_history_compactedevent.Key Changes
New Event: Added
CONVERSATION_HISTORY_COMPACTION_STARTstream event that fires before compaction begins, allowing clients to display loading states with context about the current conversation state (token count, message count, context window usage)Enhanced Compaction Event: Expanded
conversation_history_compactedevent payload with:compaction_summary: The LLM-generated summary text wrapped in<analysis>tags for debugging and verificationcompaction_costobject with detailed token usage and dollar cost of the compaction LLM callImproved Diagnostics: Added calculation and reporting of:
Updated Event Sequence: Modified the documented event flow to include the new compaction start event and an
ai_messagenotification after compaction completesImplementation Details
compact_conversation_history()call with current conversation metricscompaction_statsdictionary for consistencycompaction_usagedata is availablehttps://claude.ai/code/session_01Pmypw4hEkVU9pXgdd6j8Hq
Summary by CodeRabbit
New Features
Enhancements