Flow Curation Architecture - Claude-in-the-Loop
Design discussion: How should Claude participate in flow assignment rather than hard-coding it?
Output
Flow Curation Architecture - Claude-in-the-Loop
The Problem You've Identified
Current implementation is deterministic:
// turn-context.ts - current logic if (existingFlow) { flowId = existingFlow; // Use existing } else { flowId = autoCreate(prompt); // Create new } // Claude never gets a say!
But the emergent flow design was about loose coalescence - work naturally clustering into flows based on semantic similarity, with Claude as the curator.
Two Approaches
Option A: Turn Tells Us (Explicit)
Include active flows in context, Claude declares flow in kontask creation:
// Injected context shows active flows: <turn-context> active-flows: - flow_abc "Auth system refactor" (3 turns) - flow_def "Turn context optimization" (2 turns) - flow_ghi "Quick turn mode" (0 turns) </turn-context> // Claude explicitly chooses in kontask: konui_create_task({ title: "...", flowId: "flow_def", // or "new" for new flow flowReason: "Continuation of turn context work" });
✓ Claude makes informed decision
✓ Explicit reasoning captured
✗ Adds cognitive load to every turn
✗ More tokens in output instructions
Option B: Background Agent (Implicit)
A lightweight background process periodically analyzes recent kontasks and re-assigns flows:
// Flow Curator Agent (runs every N minutes) for (kontask of unassignedKontasks) { const matches = suggestMatchingFlows(kontask); if (matches.length > 0 && matches[0].score > threshold) { linkKontaskToFlow(kontask.id, matches[0].flow.id); } else { createFlowFromKontask(kontask); } }
✓ Zero cognitive load on turns
✓ Can re-analyze and coalesce retroactively
✗ Flow assignment is delayed
✗ Needs a scheduler (cron or long-running process)
Option C: Hybrid (Best of Both)
Show active flows in context, let Claude suggest a flow, but don't require it. Background agent cleans up.
// Context includes active flows <turn-context> active-flows: ["Auth refactor", "Turn context", "Quick turn"] </turn-context> // Kontask creation has OPTIONAL flowId konui_create_task({ title: "...", flowId?: "flow_def", // Optional - suggest a flow }); // If not specified → assigned to session's "working flow" // Background agent can re-assign later if wrong
✓ Low cognitive load (optional)
✓ Claude can steer when it's obvious
✓ Background cleanup handles edge cases
✓ Retroactive coalescence still works
Implementation Path
- Update turn-context.ts - Include top 5 active flows with titles
- Update CLAUDE.md - Explain flows are optional but encouraged
- Update kontask creation - Accept optional
flowIdfrom Claude - Later: Background curator - Periodically re-analyze and coalesce flows
Key Insight
The flow graph is eventually consistent. We don't need perfect assignment at turn time - we need a mechanism for Claude to influence assignment, and a background process to correct mistakes.
Changes Needed
| File | Change |
|---|---|
turn-context.ts |
Add activeFlows to minimal context |
router.ts |
Format flows in <turn-context> |
CLAUDE.md |
Add flowId as optional param |
kontask-db.ts |
Honor explicit flowId from Claude |
Quick Actions
Original Request
No layout configured
Details
📋 Claude's Context
ses_d3abe491...
Raw Data
{
"id": "09754d11-34fd-48f0-8517-d29ad6c54c4f",
"type": "general",
"status": "completed",
"title": "Flow Curation Architecture - Claude-in-the-Loop",
"description": "Design discussion: How should Claude participate in flow assignment rather than hard-coding it?",
"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;\">Flow Curation Architecture - Claude-in-the-Loop</h2>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">The Problem You've Identified</h3>\n<p style=\"line-height:1.6;\">Current implementation is <strong>deterministic</strong>:</p>\n<pre style=\"background:#2d2d2d;padding:16px;border-radius:6px;overflow-x:auto;line-height:1.8;color:#e0e0e0;\">\n<span style=\"color:#7f848e;\">// turn-context.ts - current logic</span>\n<span style=\"color:#c678dd;\">if</span> (existingFlow) {\n flowId = existingFlow; <span style=\"color:#7f848e;\">// Use existing</span>\n} <span style=\"color:#c678dd;\">else</span> {\n flowId = <span style=\"color:#98c379;\">autoCreate(prompt)</span>; <span style=\"color:#7f848e;\">// Create new</span>\n}\n<span style=\"color:#7f848e;\">// Claude never gets a say!</span>\n</pre>\n\n<p style=\"line-height:1.6;margin-top:12px;\">But the emergent flow design was about <em>loose coalescence</em> - work naturally clustering into flows based on semantic similarity, with Claude as the curator.</p>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Two Approaches</h3>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin:12px 0;border-left:3px solid #22c55e;\">\n<h4 style=\"color:#98c379;margin:0 0 8px 0;\">Option A: Turn Tells Us (Explicit)</h4>\n<p style=\"margin:0 0 12px 0;line-height:1.6;\">Include active flows in context, Claude declares flow in kontask creation:</p>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;font-size:0.85em;\">\n<span style=\"color:#7f848e;\">// Injected context shows active flows:</span>\n<turn-context>\n active-flows:\n - flow_abc \"Auth system refactor\" (3 turns)\n - flow_def \"Turn context optimization\" (2 turns)\n - flow_ghi \"Quick turn mode\" (0 turns)\n</turn-context>\n\n<span style=\"color:#7f848e;\">// Claude explicitly chooses in kontask:</span>\n<span style=\"color:#98c379;\">konui_create_task</span>({\n title: \"...\",\n <span style=\"color:#e5c07b;\">flowId: \"flow_def\"</span>, <span style=\"color:#7f848e;\">// or \"new\" for new flow</span>\n <span style=\"color:#e5c07b;\">flowReason: \"Continuation of turn context work\"</span>\n});\n</pre>\n<p style=\"margin:8px 0 0 0;color:#7f848e;font-size:0.9em;\">\n✓ Claude makes informed decision<br/>\n✓ Explicit reasoning captured<br/>\n✗ Adds cognitive load to every turn<br/>\n✗ More tokens in output instructions\n</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin:12px 0;border-left:3px solid #3b82f6;\">\n<h4 style=\"color:#61afef;margin:0 0 8px 0;\">Option B: Background Agent (Implicit)</h4>\n<p style=\"margin:0 0 12px 0;line-height:1.6;\">A lightweight background process periodically analyzes recent kontasks and re-assigns flows:</p>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;font-size:0.85em;\">\n<span style=\"color:#7f848e;\">// Flow Curator Agent (runs every N minutes)</span>\nfor (kontask of <span style=\"color:#98c379;\">unassignedKontasks</span>) {\n <span style=\"color:#c678dd;\">const</span> matches = <span style=\"color:#98c379;\">suggestMatchingFlows</span>(kontask);\n <span style=\"color:#c678dd;\">if</span> (matches.length > 0 && matches[0].score > threshold) {\n <span style=\"color:#98c379;\">linkKontaskToFlow</span>(kontask.id, matches[0].flow.id);\n } <span style=\"color:#c678dd;\">else</span> {\n <span style=\"color:#98c379;\">createFlowFromKontask</span>(kontask);\n }\n}\n</pre>\n<p style=\"margin:8px 0 0 0;color:#7f848e;font-size:0.9em;\">\n✓ Zero cognitive load on turns<br/>\n✓ Can re-analyze and coalesce retroactively<br/>\n✗ Flow assignment is delayed<br/>\n✗ Needs a scheduler (cron or long-running process)\n</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin:12px 0;border-left:3px solid #8b5cf6;\">\n<h4 style=\"color:#c678dd;margin:0 0 8px 0;\">Option C: Hybrid (Best of Both)</h4>\n<p style=\"margin:0 0 12px 0;line-height:1.6;\">Show active flows in context, let Claude <em>suggest</em> a flow, but don't require it. Background agent cleans up.</p>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;font-size:0.85em;\">\n<span style=\"color:#7f848e;\">// Context includes active flows</span>\n<turn-context>\n active-flows: [\"Auth refactor\", \"Turn context\", \"Quick turn\"]\n</turn-context>\n\n<span style=\"color:#7f848e;\">// Kontask creation has OPTIONAL flowId</span>\n<span style=\"color:#98c379;\">konui_create_task</span>({\n title: \"...\",\n <span style=\"color:#e5c07b;\">flowId?: \"flow_def\"</span>, <span style=\"color:#7f848e;\">// Optional - suggest a flow</span>\n});\n\n<span style=\"color:#7f848e;\">// If not specified → assigned to session's \"working flow\"</span>\n<span style=\"color:#7f848e;\">// Background agent can re-assign later if wrong</span>\n</pre>\n<p style=\"margin:8px 0 0 0;color:#7f848e;font-size:0.9em;\">\n✓ Low cognitive load (optional)<br/>\n✓ Claude can steer when it's obvious<br/>\n✓ Background cleanup handles edge cases<br/>\n✓ Retroactive coalescence still works\n</p>\n</div>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Implementation Path</h3>\n\n<ol style=\"margin:12px 0;padding-left:24px;line-height:1.8;\">\n<li><strong>Update turn-context.ts</strong> - Include top 5 active flows with titles</li>\n<li><strong>Update CLAUDE.md</strong> - Explain flows are optional but encouraged</li>\n<li><strong>Update kontask creation</strong> - Accept optional <code>flowId</code> from Claude</li>\n<li><strong>Later: Background curator</strong> - Periodically re-analyze and coalesce flows</li>\n</ol>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Key Insight</h3>\n<p style=\"line-height:1.6;padding:12px;background:rgba(97,175,239,0.1);border-radius:6px;border:1px solid rgba(97,175,239,0.3);\">\nThe flow graph is <strong>eventually consistent</strong>. We don't need perfect assignment at turn time - we need a mechanism for Claude to <em>influence</em> assignment, and a background process to <em>correct</em> mistakes.\n</p>\n\n<h3 style=\"color:#61afef;margin:20px 0 12px 0;\">Changes Needed</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;\">File</th>\n<th style=\"text-align:left;padding:8px;border:1px solid #444;\">Change</th>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\"><code>turn-context.ts</code></td>\n<td style=\"padding:8px;border:1px solid #444;\">Add <code>activeFlows</code> to minimal context</td>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\"><code>router.ts</code></td>\n<td style=\"padding:8px;border:1px solid #444;\">Format flows in <code><turn-context></code></td>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\"><code>CLAUDE.md</code></td>\n<td style=\"padding:8px;border:1px solid #444;\">Add <code>flowId</code> as optional param</td>\n</tr>\n<tr>\n<td style=\"padding:8px;border:1px solid #444;\"><code>kontask-db.ts</code></td>\n<td style=\"padding:8px;border:1px solid #444;\">Honor explicit <code>flowId</code> from Claude</td>\n</tr>\n</table>\n\n</div>",
"requestedAt": "2026-01-09T13:10:00.000Z",
"requestId": "cabfef70-2762-48ff-85c2-bc02a5537c91",
"choices": [
{
"label": "Option C (Hybrid)",
"value": "Implement the hybrid approach: show active flows in context, let Claude optionally specify flowId, plan for background curator later",
"primary": true
},
{
"label": "Option A (Explicit)",
"value": "Implement explicit flow selection: require Claude to always specify a flowId when creating kontasks"
},
{
"label": "Option B (Background)",
"value": "Skip turn-time flow assignment entirely, implement background flow curator agent"
},
{
"label": "Discuss more",
"value": "I want to explore this design further before implementation"
}
],
"turnTiming": {
"totalMs": 383357,
"ttfeMs": 124,
"thinkingMs": 383233,
"toolExecutionMs": 0,
"toolCallCount": 0,
"thinkingPct": 100,
"toolsPct": 0,
"ttfePct": 0
}
},
"createdBy": "claude",
"createdAt": "2026-01-09T13:12:45.614Z",
"updatedAt": "2026-01-09T13:18:20.799Z",
"requestId": "cabfef70-2762-48ff-85c2-bc02a5537c91",
"scope": "vibetools",
"tags": [
"flows",
"architecture",
"design"
],
"sessionId": "ses_d3abe491-395",
"flowId": "flow_01KEGVRXHHK7E25VFSX4HCV289",
"flowLinks": [
{
"flowId": "flow_01KEGVRXHHK7E25VFSX4HCV289",
"edgeType": "evidence",
"createdAt": "2026-01-09T13:12:45.614Z"
}
],
"targetUser": "claude"
}