← Back to Kontasks
Parallel Connection Architecture Analysis
Analysis of using hooks as parallel data channels for compaction tracking
Output
Parallel Data Channels for Compaction
Key Discovery: PreCompact Hook
There's a PreCompact hook that fires before compaction starts!
{
"hook_event_name": "PreCompact",
"trigger": "auto" | "manual",
"session_id": "abc123...",
"custom_instructions": null
}Proposed Architecture
┌─────────────────────────────────────────────────────────────┐
│ Claude Process │
│ ┌─────────┐ ┌─────────┐ ┌─────────────────────┐ │
│ │ stream- │ │ Status │ │ PreCompact Hook │ │
│ │ json │ │ Line │ │ (fires @ start) │ │
│ │ output │ │ hook │ └──────────┬──────────┘ │
│ └────┬────┘ └────┬────┘ │ │
│ │ │ │ │
└───────┼──────────────┼─────────────────────┼─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────┐ ┌─────────────┐ ┌──────────────┐
│ konsole │ │ statusline │ │ precompact │
│ stream │ │ POST to │ │ POST to │
│ handler │ │ /api/status │ │ /api/compact │
└────┬────┘ └──────┬──────┘ └───────┬──────┘
│ │ │
└───────────────┴──────────────────────┘
│
▼
┌────────────────┐
│ konui │
│ - correlate │
│ - compute Δt │
└────────────────┘
How Duration Measurement Would Work
| 1. PreCompact hook fires | POST {sessionId, event: 'compact_start', trigger, timestamp} |
| 2. Compaction runs | 45-90 seconds (no events in stream) |
| 3. compact_boundary event | Arrives in stream-json with pre_tokens |
| 4. konui correlates | duration = boundary_time - start_time |
Bonus: StatusLine During Compaction
StatusLine updates every 300ms during conversation. During compaction:
- Context tokens may drop suddenly (post-compaction)
- Can detect "context window shrunk" pattern
- Provides secondary confirmation of compaction completion
Implementation Steps
- Add
PreCompacthook to~/.claude/settings.json - Create
/konnectvol/bin/precompact-tracker.sh - Add
POST /api/compactendpoint to konui - Correlate with
compact_boundaryevents in stream - Calculate actual duration from timestamps
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
telemetrycompactionarchitecture
Created
4 Jan 2026, 11:14 am
Updated
4 Jan 2026, 11:14 am
Timing
⏱️ 103.3s
8 tools
● TTFE 4%
● Thinking 71%
● Tools 25%
Created By
claude
Raw Data
{
"id": "f7ff5da9-93c6-4ff8-81a8-506c2fa9e351",
"type": "general",
"status": "completed",
"title": "Parallel Connection Architecture Analysis",
"description": "Analysis of using hooks as parallel data channels for compaction tracking",
"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;\">Parallel Data Channels for Compaction</h2><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#98c379;margin:0 0 12px 0;\">Key Discovery: PreCompact Hook</h3><p style=\"margin:0 0 12px 0;\">There's a <strong>PreCompact</strong> hook that fires <em>before</em> compaction starts!</p><pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;margin:0;font-size:0.85rem;overflow-x:auto;\">{\n <span style=\"color:#98c379;\">\"hook_event_name\"</span>: <span style=\"color:#e5c07b;\">\"PreCompact\"</span>,\n <span style=\"color:#98c379;\">\"trigger\"</span>: <span style=\"color:#e5c07b;\">\"auto\"</span> | <span style=\"color:#e5c07b;\">\"manual\"</span>,\n <span style=\"color:#98c379;\">\"session_id\"</span>: <span style=\"color:#e5c07b;\">\"abc123...\"</span>,\n <span style=\"color:#98c379;\">\"custom_instructions\"</span>: <span style=\"color:#c678dd;\">null</span>\n}</pre></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#61afef;margin:0 0 12px 0;\">Proposed Architecture</h3><pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;margin:0;font-size:0.75rem;overflow-x:auto;line-height:1.6;\">\n┌─────────────────────────────────────────────────────────────┐\n│ Claude Process │\n│ ┌─────────┐ ┌─────────┐ ┌─────────────────────┐ │\n│ │ stream- │ │ Status │ │ PreCompact Hook │ │\n│ │ json │ │ Line │ │ (fires @ start) │ │\n│ │ output │ │ hook │ └──────────┬──────────┘ │\n│ └────┬────┘ └────┬────┘ │ │\n│ │ │ │ │\n└───────┼──────────────┼─────────────────────┼─────────────────┘\n │ │ │\n ▼ ▼ ▼\n ┌─────────┐ ┌─────────────┐ ┌──────────────┐\n │ konsole │ │ statusline │ │ precompact │\n │ stream │ │ POST to │ │ POST to │\n │ handler │ │ /api/status │ │ /api/compact │\n └────┬────┘ └──────┬──────┘ └───────┬──────┘\n │ │ │\n └───────────────┴──────────────────────┘\n │\n ▼\n ┌────────────────┐\n │ konui │\n │ - correlate │\n │ - compute Δt │\n └────────────────┘\n</pre></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#c678dd;margin:0 0 12px 0;\">How Duration Measurement Would Work</h3><table style=\"width:100%;border-collapse:collapse;font-size:0.9rem;\"><tr style=\"border-bottom:1px solid #444;\"><td style=\"padding:8px;color:#e5c07b;\">1. PreCompact hook fires</td><td style=\"padding:8px;\">POST <code>{sessionId, event: 'compact_start', trigger, timestamp}</code></td></tr><tr style=\"border-bottom:1px solid #444;\"><td style=\"padding:8px;color:#e5c07b;\">2. Compaction runs</td><td style=\"padding:8px;\">45-90 seconds (no events in stream)</td></tr><tr style=\"border-bottom:1px solid #444;\"><td style=\"padding:8px;color:#e5c07b;\">3. compact_boundary event</td><td style=\"padding:8px;\">Arrives in stream-json with <code>pre_tokens</code></td></tr><tr><td style=\"padding:8px;color:#e5c07b;\">4. konui correlates</td><td style=\"padding:8px;\"><code>duration = boundary_time - start_time</code></td></tr></table></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><h3 style=\"color:#f97316;margin:0 0 12px 0;\">Bonus: StatusLine During Compaction</h3><p style=\"margin:0 0 8px 0;\">StatusLine updates every <strong>300ms</strong> during conversation. During compaction:</p><ul style=\"margin:0;padding-left:20px;line-height:1.8;\"><li>Context tokens may drop suddenly (post-compaction)</li><li>Can detect \"context window shrunk\" pattern</li><li>Provides secondary confirmation of compaction completion</li></ul></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;\"><h4 style=\"margin:0 0 8px 0;color:#fff;\">Implementation Steps</h4><ol style=\"margin:0;padding-left:20px;line-height:1.8;\"><li>Add <code>PreCompact</code> hook to <code>~/.claude/settings.json</code></li><li>Create <code>/konnectvol/bin/precompact-tracker.sh</code></li><li>Add <code>POST /api/compact</code> endpoint to konui</li><li>Correlate with <code>compact_boundary</code> events in stream</li><li>Calculate actual duration from timestamps</li></ol></div></div>",
"requestId": "2573ba9d-f8d4-4277-adb6-9a795867953b",
"choices": [
{
"label": "Implement this",
"value": "Implement the PreCompact hook + endpoint architecture for precise compaction duration tracking",
"primary": true
},
{
"label": "Just use PreCompact",
"value": "Add PreCompact hook to track compaction count without duration"
},
{
"label": "More research",
"value": "Research more about what data is available in hooks and StatusLine"
}
],
"turnTiming": {
"totalMs": 103293,
"ttfeMs": 3841,
"thinkingMs": 73152,
"toolExecutionMs": 26298,
"toolCallCount": 8,
"thinkingPct": 71,
"toolsPct": 25,
"ttfePct": 4
}
},
"createdBy": "claude",
"createdAt": "2026-01-04T01:14:09.762Z",
"updatedAt": "2026-01-04T01:14:18.237Z",
"requestId": "2573ba9d-f8d4-4277-adb6-9a795867953b",
"scope": "vibetools",
"tags": [
"telemetry",
"compaction",
"architecture"
],
"targetUser": "claude"
}