← Back to Kontasks
Hybrid Turn Context Injection Implemented
Implemented auto-injected turn context to eliminate 6+ tool calls at turn start
Output
✅ Hybrid Turn Context Injection Implemented
What Changed
konui/src/ ├── turn-context.ts # NEW - minimal & full context functions └── router.ts # Inject <turn-context> into prompts konui/mcp/ └── server.ts # Add konui_get_turn_context MCP tool /konnectvol/ └── CLAUDE.md # Remove turn-start tool requirements
How It Works
Before (6+ tool calls at turn start)
❌ konui_get_recent_kontasks ❌ konui_get_backlog ❌ konui_get_active_flows ❌ Read /konnectvol/gv/VIBE.md ❌ konui_get_decision_stats ❌ konui_list_decisions
After (0 tool calls - context is pre-injected)
<turn-context session="ses_abc123"> flow: flow_xyz "Fix auth bug" recent: "Schema refactor", "Type fixes", "API update" ⚡ 2 approved task(s) awaiting processing </turn-context> DASHBOARD CONSOLE REQUEST from user "stephanie": ...
Impact
| Metric | Before | After |
|---|---|---|
| Tool calls at turn start | 6+ | 0 |
| Tokens for context | ~3,000+ | ~150 |
| Turn start latency | 5-10s | 0s |
New MCP Tool
When Claude needs more context than the pre-injected tag:
await konui_get_turn_context({ scope: "vibetools" }); // Returns: recentKontasks, activeFlow, approvedTasks, backlogHints
Files Changed
konui/src/turn-context.ts- NEW (307 lines)konui/src/router.ts- Inject context (+11 lines)konui/mcp/server.ts- Add MCP tool (+40 lines)CLAUDE.md- Update instructions (-41/+31 lines)
Commit: bfea6143 - Turn: Implement hybrid turn context injection
Next: Restart konui to apply changes. Then test that Claude no longer makes 6+ tool calls at turn start.
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
kontasksflowscontextperformance
Created
9 Jan 2026, 11:07 pm
Updated
9 Jan 2026, 11:07 pm
Timing
⏱️ 348.5s
0 tools
● TTFE 0%
● Thinking 100%
● Tools 0%
Created By
claude
📋 Claude's Context
Session
ses_d3abe491...
🔗 Git Commit
bfea6143
📁 4 files changed
konui/src/turn-context.tskonui/src/router.tskonui/mcp/server.tsCLAUDE.md
Raw Data
{
"id": "a32bc1b3-5d72-49db-9274-29341a8dd783",
"type": "general",
"status": "completed",
"title": "Hybrid Turn Context Injection Implemented",
"description": "Implemented auto-injected turn context to eliminate 6+ tool calls at turn start",
"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;\">✅ Hybrid Turn Context Injection Implemented</h2>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">What Changed</h3>\n\n<pre style=\"background:#2d2d2d;padding:16px;border-radius:6px;overflow-x:auto;line-height:1.8;color:#e0e0e0;\">\n<span style=\"color:#56b6c2;font-weight:bold;\">konui/src/</span>\n├── <span style=\"color:#98c379;font-weight:bold;\">turn-context.ts</span> <span style=\"color:#7f848e;\"># NEW - minimal & full context functions</span>\n└── <span style=\"color:#e5c07b;\">router.ts</span> <span style=\"color:#7f848e;\"># Inject <turn-context> into prompts</span>\n\n<span style=\"color:#56b6c2;font-weight:bold;\">konui/mcp/</span>\n└── <span style=\"color:#e5c07b;\">server.ts</span> <span style=\"color:#7f848e;\"># Add konui_get_turn_context MCP tool</span>\n\n<span style=\"color:#56b6c2;font-weight:bold;\">/konnectvol/</span>\n└── <span style=\"color:#e5c07b;\">CLAUDE.md</span> <span style=\"color:#7f848e;\"># Remove turn-start tool requirements</span>\n</pre>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">How It Works</h3>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin:12px 0;\">\n<h4 style=\"color:#98c379;margin:0 0 8px 0;\">Before (6+ tool calls at turn start)</h4>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;font-size:0.85em;color:#e06c75;\">\n❌ konui_get_recent_kontasks\n❌ konui_get_backlog \n❌ konui_get_active_flows\n❌ Read /konnectvol/gv/VIBE.md\n❌ konui_get_decision_stats\n❌ konui_list_decisions\n</pre>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin:12px 0;\">\n<h4 style=\"color:#98c379;margin:0 0 8px 0;\">After (0 tool calls - context is pre-injected)</h4>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;font-size:0.85em;color:#98c379;\">\n<turn-context session=\"ses_abc123\">\n flow: flow_xyz \"Fix auth bug\"\n recent: \"Schema refactor\", \"Type fixes\", \"API update\"\n ⚡ 2 approved task(s) awaiting processing\n</turn-context>\n\nDASHBOARD CONSOLE REQUEST from user \"stephanie\":\n...\n</pre>\n</div>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Impact</h3>\n<table style=\"width:100%;border-collapse:collapse;margin:12px 0;\">\n<tr style=\"background:#2d2d2d;\">\n<th style=\"text-align:left;padding:8px;border:1px solid #444;\">Metric</th>\n<th style=\"text-align:left;padding:8px;border:1px solid #444;\">Before</th>\n<th style=\"text-align:left;padding:8px;border:1px solid #444;\">After</th>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\">Tool calls at turn start</td>\n<td style=\"padding:8px;border:1px solid #444;color:#e06c75;\">6+</td>\n<td style=\"padding:8px;border:1px solid #444;color:#98c379;\">0</td>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\">Tokens for context</td>\n<td style=\"padding:8px;border:1px solid #444;color:#e06c75;\">~3,000+</td>\n<td style=\"padding:8px;border:1px solid #444;color:#98c379;\">~150</td>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\">Turn start latency</td>\n<td style=\"padding:8px;border:1px solid #444;color:#e06c75;\">5-10s</td>\n<td style=\"padding:8px;border:1px solid #444;color:#98c379;\">0s</td>\n</tr>\n</table>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">New MCP Tool</h3>\n<p style=\"line-height:1.6;\">When Claude needs <em>more</em> context than the pre-injected tag:</p>\n<pre style=\"background:#2d2d2d;padding:12px;border-radius:6px;font-size:0.9em;\">\n<span style=\"color:#c678dd;\">await</span> <span style=\"color:#98c379;\">konui_get_turn_context</span>({ scope: <span style=\"color:#e5c07b;\">\"vibetools\"</span> });\n<span style=\"color:#7f848e;\">// Returns: recentKontasks, activeFlow, approvedTasks, backlogHints</span>\n</pre>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Files Changed</h3>\n<ul style=\"margin:12px 0;padding-left:24px;line-height:1.8;\">\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:4px;\">konui/src/turn-context.ts</code> - NEW (307 lines)</li>\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:4px;\">konui/src/router.ts</code> - Inject context (+11 lines)</li>\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:4px;\">konui/mcp/server.ts</code> - Add MCP tool (+40 lines)</li>\n<li><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:4px;\">CLAUDE.md</code> - Update instructions (-41/+31 lines)</li>\n</ul>\n\n<p style=\"margin-top:20px;padding:12px;background:rgba(34,197,94,0.1);border-radius:6px;border:1px solid rgba(34,197,94,0.3);\">\n<strong style=\"color:#22c55e;\">Commit:</strong> <code style=\"background:#3d3d3d;padding:2px 6px;border-radius:4px;\">bfea6143</code> - Turn: Implement hybrid turn context injection\n</p>\n\n<p style=\"margin-top:12px;padding:12px;background:rgba(59,130,246,0.1);border-radius:6px;border:1px solid rgba(59,130,246,0.3);\">\n<strong style=\"color:#3b82f6;\">Next:</strong> Restart konui to apply changes. Then test that Claude no longer makes 6+ tool calls at turn start.\n</p>\n\n</div>",
"requestedAt": "2026-01-09T13:05:00.000Z",
"requestId": "83b2fbcd-2aa2-4fd5-b628-0df81390435f",
"commitSha": "bfea6143",
"filesChanged": [
"konui/src/turn-context.ts",
"konui/src/router.ts",
"konui/mcp/server.ts",
"CLAUDE.md"
],
"choices": [
{
"label": "Restart konui",
"value": "Restart konui to apply the turn context changes",
"primary": true
},
{
"label": "Test now",
"value": "Send a test prompt to see if context is injected (without restart)"
},
{
"label": "Review code",
"value": "Show me the turn-context.ts file contents"
}
],
"turnTiming": {
"totalMs": 348478,
"ttfeMs": 50,
"thinkingMs": 348428,
"toolExecutionMs": 0,
"toolCallCount": 0,
"thinkingPct": 100,
"toolsPct": 0,
"ttfePct": 0
}
},
"createdBy": "claude",
"createdAt": "2026-01-09T13:07:25.518Z",
"updatedAt": "2026-01-09T13:07:32.007Z",
"requestId": "83b2fbcd-2aa2-4fd5-b628-0df81390435f",
"scope": "vibetools",
"tags": [
"kontasks",
"flows",
"context",
"performance"
],
"sessionId": "ses_d3abe491-395",
"flowId": "flow_01KEGVRXHHK7E25VFSX4HCV289",
"flowLinks": [
{
"flowId": "flow_01KEGVRXHHK7E25VFSX4HCV289",
"edgeType": "evidence",
"createdAt": "2026-01-09T13:07:25.518Z"
}
],
"targetUser": "claude"
}