← Back to Kontasks
Compaction tracking completely reworked
Fixed compaction stats - now tracks actual duration (45-90s) instead of turn time (17min)
Output
Compaction Tracking Reworked
Root Cause Analysis
The telemetry showed p95 turn time = 1023.9s (17 min!) for compaction turns because:
- Claude emits
compact_boundaryONCE at compaction start - There's NO explicit "compaction ended" event from Claude
- We infer end when next non-system event arrives (unreliable)
compactionDurationMswas alwaysnullin telemetry- Fallback to turn time (entire turn, not just compaction) was misleading
Changes Made
1. konsole/src/stream.ts - Server-side duration tracking
- Changed
isCompacting: boolean→compactionStartedAt: number(timestamp) auto_compactevent now includesstartedAttimestampauto_compact_endevent now includesdurationMs(calculated server-side)
2. konsole/src/types.ts - Updated event types
// Before
| { type: "auto_compact" }
| { type: "auto_compact_end" }
// After
| { type: "auto_compact"; startedAt?: number }
| { type: "auto_compact_end"; durationMs?: number }
3. konui/src/console-event-handler.ts - Client uses server duration
- Prefers server-provided
durationMsif available - Falls back to local timing only if server doesn't provide it
4. konui/src/telemetry-calculations.ts - New metrics
// Before (wrong - used turn time as fallback)
interface CompactionStats {
p95TurnTime: number; // 1023s - WRONG!
p95CompactionDuration: number;
}
// After (correct - only actual duration)
interface CompactionStats {
trackedCount: number; // How many have duration data
avgDurationMs: number; // Average actual compaction
minDurationMs: number; // Range min
maxDurationMs: number; // Range max
}
New Telemetry Display
The telemetry page now shows:
- Compaction turns: Total count of turns with compaction
- Avg duration: Average of ACTUAL compaction times (expected 45-90s)
- Range: Min-max of actual compaction times
- Tracked count: "X of Y compactions have duration data"
If no duration data exists: "No compaction duration data yet. Duration tracking requires both start and end events from Claude."
Files Changed
konsole/src/stream.ts- Server-side duration trackingkonsole/src/types.ts- Event type updateskonui/src/console-event-handler.ts- Client duration handlingkonui/src/telemetry-calculations.ts- New metricskonui/src/views/telemetry.ts- Updated display
What's Next?
Restart konsole to enable duration tracking. New compactions will have accurate duration data.
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
telemetrycompactionbugfix
Created
4 Jan 2026, 10:36 am
Updated
4 Jan 2026, 10:37 am
Timing
⏱️ 285.9s
40 tools
● TTFE 1%
● Thinking 91%
● Tools 7%
Created By
claude
Raw Data
{
"id": "d4150c4c-05b3-4dab-8588-0b58143d7e3c",
"type": "general",
"status": "completed",
"title": "Compaction tracking completely reworked",
"description": "Fixed compaction stats - now tracks actual duration (45-90s) instead of turn time (17min)",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:'Consolas','Monaco',monospace;\">\n<h2 style=\"font-family:sans-serif;color:#fff;margin:0 0 16px 0;\">Compaction Tracking Reworked</h2>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"font-family:sans-serif;color:#f87171;margin:0 0 12px 0;\">Root Cause Analysis</h3>\n<p style=\"margin:0 0 12px 0;color:#e0e0e0;\">The telemetry showed <strong>p95 turn time = 1023.9s (17 min!)</strong> for compaction turns because:</p>\n<ol style=\"margin:0;padding-left:20px;color:#e0e0e0;line-height:1.8;\">\n<li>Claude emits <code style=\"background:#1e1e1e;padding:2px 6px;border-radius:3px;\">compact_boundary</code> ONCE at compaction start</li>\n<li>There's NO explicit \"compaction ended\" event from Claude</li>\n<li>We infer end when next non-system event arrives (unreliable)</li>\n<li><code style=\"background:#1e1e1e;padding:2px 6px;border-radius:3px;\">compactionDurationMs</code> was always <code>null</code> in telemetry</li>\n<li>Fallback to <strong>turn time</strong> (entire turn, not just compaction) was misleading</li>\n</ol>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"font-family:sans-serif;color:#4ade80;margin:0 0 12px 0;\">Changes Made</h3>\n\n<h4 style=\"color:#fbbf24;margin:12px 0 8px 0;\">1. konsole/src/stream.ts - Server-side duration tracking</h4>\n<ul style=\"margin:0;padding-left:20px;color:#e0e0e0;line-height:1.6;\">\n<li>Changed <code>isCompacting: boolean</code> → <code>compactionStartedAt: number</code> (timestamp)</li>\n<li><code>auto_compact</code> event now includes <code>startedAt</code> timestamp</li>\n<li><code>auto_compact_end</code> event now includes <code>durationMs</code> (calculated server-side)</li>\n</ul>\n\n<h4 style=\"color:#fbbf24;margin:12px 0 8px 0;\">2. konsole/src/types.ts - Updated event types</h4>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;overflow-x:auto;color:#98c379;margin:8px 0 0 0;\">// Before\n| { type: \"auto_compact\" }\n| { type: \"auto_compact_end\" }\n\n// After\n| { type: \"auto_compact\"; startedAt?: number }\n| { type: \"auto_compact_end\"; durationMs?: number }</pre>\n\n<h4 style=\"color:#fbbf24;margin:12px 0 8px 0;\">3. konui/src/console-event-handler.ts - Client uses server duration</h4>\n<ul style=\"margin:0;padding-left:20px;color:#e0e0e0;line-height:1.6;\">\n<li>Prefers server-provided <code>durationMs</code> if available</li>\n<li>Falls back to local timing only if server doesn't provide it</li>\n</ul>\n\n<h4 style=\"color:#fbbf24;margin:12px 0 8px 0;\">4. konui/src/telemetry-calculations.ts - New metrics</h4>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;overflow-x:auto;color:#98c379;margin:8px 0 0 0;\">// Before (wrong - used turn time as fallback)\ninterface CompactionStats {\n p95TurnTime: number; // 1023s - WRONG!\n p95CompactionDuration: number;\n}\n\n// After (correct - only actual duration)\ninterface CompactionStats {\n trackedCount: number; // How many have duration data\n avgDurationMs: number; // Average actual compaction\n minDurationMs: number; // Range min\n maxDurationMs: number; // Range max\n}</pre>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"font-family:sans-serif;color:#61afef;margin:0 0 12px 0;\">New Telemetry Display</h3>\n<p style=\"margin:0 0 8px 0;color:#9ca3af;\">The telemetry page now shows:</p>\n<ul style=\"margin:0;padding-left:20px;color:#e0e0e0;line-height:1.8;\">\n<li><strong>Compaction turns</strong>: Total count of turns with compaction</li>\n<li><strong>Avg duration</strong>: Average of ACTUAL compaction times (expected 45-90s)</li>\n<li><strong>Range</strong>: Min-max of actual compaction times</li>\n<li><strong>Tracked count</strong>: \"X of Y compactions have duration data\"</li>\n</ul>\n<p style=\"margin:12px 0 0 0;color:#9ca3af;font-size:0.85rem;\">If no duration data exists: \"No compaction duration data yet. Duration tracking requires both start and end events from Claude.\"</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"font-family:sans-serif;color:#c678dd;margin:0 0 12px 0;\">Files Changed</h3>\n<ul style=\"margin:0;padding-left:20px;color:#9ca3af;line-height:1.6;\">\n<li><code>konsole/src/stream.ts</code> - Server-side duration tracking</li>\n<li><code>konsole/src/types.ts</code> - Event type updates</li>\n<li><code>konui/src/console-event-handler.ts</code> - Client duration handling</li>\n<li><code>konui/src/telemetry-calculations.ts</code> - New metrics</li>\n<li><code>konui/src/views/telemetry.ts</code> - Updated display</li>\n</ul>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;font-family:sans-serif;\">\n<h4 style=\"margin:0 0 8px 0;color:#fff;\">What's Next?</h4>\n<p style=\"color:#9ca3af;margin:0;\">Restart konsole to enable duration tracking. New compactions will have accurate duration data.</p>\n</div>\n</div>",
"choices": [
{
"label": "Restart konsole",
"value": "Restart konsole service to enable the new compaction tracking",
"primary": true
},
{
"label": "Restart konui too",
"value": "Restart both konsole and konui services"
},
{
"label": "Check telemetry",
"value": "Show me the current telemetry page to verify the new display"
}
],
"requestedAt": "2026-01-04T10:30:00.000Z",
"requestId": "a2462339-5162-4310-92c6-9d5f0fb51989",
"turnTiming": {
"totalMs": 285885,
"ttfeMs": 3975,
"thinkingMs": 260975,
"toolExecutionMs": 20932,
"toolCallCount": 40,
"thinkingPct": 91,
"toolsPct": 7,
"ttfePct": 1
}
},
"createdBy": "claude",
"createdAt": "2026-01-04T00:36:53.016Z",
"updatedAt": "2026-01-04T00:37:00.861Z",
"requestId": "a2462339-5162-4310-92c6-9d5f0fb51989",
"scope": "vibetools",
"tags": [
"telemetry",
"compaction",
"bugfix"
],
"targetUser": "claude"
}