Architecture: How should sub-Vitto SSE events be scoped to avoid polluting...
Documentation for Sessions
🏗️ Architecture: How should sub-Vitto SSE events be scoped to avoid polluting...
Date: 2026-03-18
Time: 16:42:07 UTC
Session: gspace1-234.5
Agent: backend
Confidence: 93%
Status: ✅ Documented
📋 Decision Context
Question:
How should sub-Vitto SSE events be scoped to avoid polluting the parent event stream?
Task: S234.2: Sub-Vitto Engine - SSE event scoping
🎯 Decision Made
Chosen:
Created SubVittoSSEProxy — a lightweight wrapper that subscribes to a child Subject, maps event types via a static TYPE_MAP (agent.iteration→subvitto.progress, tool.called→subvitto.tool, etc.), injects subTaskId/parentTaskId metadata, and forwards to the parent Subject. Disposed per-task in finally blocks.
Options Considered:
- Modify AgentLoopService to accept event type prefix
- Post-filter events on frontend by taskId
- SubVittoSSEProxy wrapper (chosen)
- Separate SSE endpoints per sub-Vitto
💭 Reasoning
Without scoping, sub-Vitto events (agent.iteration, tool.called) are indistinguishable from the parent's events in the SSE stream. The proxy pattern was chosen over: (1) modifying AgentLoopService to accept a type prefix (invasive, breaks all callers), (2) post-filtering on the frontend (wasteful, requires all events to be sent), (3) using separate SSE endpoints per sub-Vitto (complex, requires dynamic endpoint creation). The proxy is ~55 lines, has zero NestJS dependencies, and follows the same delegation pattern as WhatsAppProgressEmitter. The TYPE_MAP is extensible — adding new event mappings is a one-line change.
📁 Files Involved
APIs/backend-vitto-api/src/app/engine/sub-vitto-sse-proxy.ts
🔗 Related
- Decision ID:
dev_1773852127563_0dhkf4e - Session: 234
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation