Completed
on 4 Jan 2026, 11:08 am

Output

Compaction Event Research

Key Finding

Compaction is a boundary marker, not a start/end pair. By the time we receive the event, compaction is already complete.

Official SDK Type

type SDKCompactBoundaryMessage = {
  type: 'system';
  subtype: 'compact_boundary';
  uuid: UUID;
  session_id: string;
  compact_metadata: {
    trigger: 'manual' | 'auto';
    pre_tokens: number; // tokens BEFORE compaction
  };
}

What This Means

  • No compaction_start / compaction_end events exist
  • Duration cannot be measured from stream events
  • We can only know: compaction happened, trigger type, pre-token count
  • Claude Code CLI shows compaction UI differently (not duration-based)

Recommendation

Remove compaction duration tracking entirely. Instead, track:

  • Compaction count - How many turns had compaction
  • Compaction percentage - % of recent turns
  • Pre-tokens - Context size before compaction (from compact_metadata.pre_tokens)

Quick Actions

Original Request

No layout configured

Details

Type General
Status Completed
Scope vibetools
Tags telemetrycompactionresearch
Created 4 Jan 2026, 11:08 am
Updated 4 Jan 2026, 11:08 am
Timing
⏱️ 161.7s
14 tools
TTFE 2% Thinking 53% Tools 45%
Created By claude

Raw Data

{
  "id": "f1e0f8b9-086c-47b0-9dcb-b066c220b90a",
  "type": "general",
  "status": "completed",
  "title": "Compaction Event Research Results",
  "description": "Found official SDK documentation - compaction is a boundary marker, not start/end pair",
  "context": {
    "output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:system-ui,sans-serif;\"><h2 style=\"color:#fff;margin:0 0 16px 0;\">Compaction Event Research</h2><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#61afef;margin:0 0 12px 0;\">Key Finding</h3><p style=\"margin:0;\">Compaction is a <strong>boundary marker</strong>, not a start/end pair. By the time we receive the event, compaction is already complete.</p></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#98c379;margin:0 0 12px 0;\">Official SDK Type</h3><pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;margin:0;font-size:0.85rem;overflow-x:auto;\"><span style=\"color:#c678dd;\">type</span> SDKCompactBoundaryMessage = {\n  type: <span style=\"color:#98c379;\">'system'</span>;\n  subtype: <span style=\"color:#98c379;\">'compact_boundary'</span>;\n  uuid: UUID;\n  session_id: <span style=\"color:#c678dd;\">string</span>;\n  compact_metadata: {\n    trigger: <span style=\"color:#98c379;\">'manual'</span> | <span style=\"color:#98c379;\">'auto'</span>;\n    pre_tokens: <span style=\"color:#c678dd;\">number</span>; <span style=\"color:#7f848e;\">// tokens BEFORE compaction</span>\n  };\n}</pre></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#e5c07b;margin:0 0 12px 0;\">What This Means</h3><ul style=\"margin:0;padding-left:20px;line-height:1.8;\"><li>No <code>compaction_start</code> / <code>compaction_end</code> events exist</li><li>Duration cannot be measured from stream events</li><li>We can only know: compaction happened, trigger type, pre-token count</li><li>Claude Code CLI shows compaction UI differently (not duration-based)</li></ul></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#c678dd;margin:0 0 12px 0;\">Recommendation</h3><p style=\"margin:0 0 12px 0;\">Remove compaction duration tracking entirely. Instead, track:</p><ul style=\"margin:0;padding-left:20px;line-height:1.8;\"><li><strong>Compaction count</strong> - How many turns had compaction</li><li><strong>Compaction percentage</strong> - % of recent turns</li><li><strong>Pre-tokens</strong> - Context size before compaction (from <code>compact_metadata.pre_tokens</code>)</li></ul></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;\"><h4 style=\"margin:0 0 8px 0;color:#fff;\">Sources</h4><ul style=\"margin:0;padding-left:20px;color:#9ca3af;font-size:0.9rem;\"><li><a href=\"https://platform.claude.com/docs/en/agent-sdk/typescript\" style=\"color:#61afef;\">Agent SDK TypeScript Reference</a></li><li><a href=\"https://github.com/anthropics/claude-code\" style=\"color:#61afef;\">Claude Code GitHub</a></li></ul></div></div>",
    "requestId": "4f3dd48e-8175-49b5-af7f-9c1d2ff84910",
    "choices": [
      {
        "label": "Remove duration tracking",
        "value": "Remove compaction duration tracking from telemetry and only track count/percentage/pre-tokens",
        "primary": true
      },
      {
        "label": "Revert my fix",
        "value": "Revert the stream.ts compaction end fix I just added"
      },
      {
        "label": "Keep current approach",
        "value": "Keep the current approach but understand its limitations"
      }
    ],
    "turnTiming": {
      "totalMs": 161659,
      "ttfeMs": 3357,
      "thinkingMs": 85510,
      "toolExecutionMs": 72791,
      "toolCallCount": 14,
      "thinkingPct": 53,
      "toolsPct": 45,
      "ttfePct": 2
    }
  },
  "createdBy": "claude",
  "createdAt": "2026-01-04T01:08:07.980Z",
  "updatedAt": "2026-01-04T01:08:14.737Z",
  "requestId": "4f3dd48e-8175-49b5-af7f-9c1d2ff84910",
  "scope": "vibetools",
  "tags": [
    "telemetry",
    "compaction",
    "research"
  ],
  "targetUser": "claude"
}
DashboardReportsKontasksSessionsTelemetryLogs + Go