Repository navigation
Closed
Labels
complexity-mediumComplexity: medium (board points 5-8)priority-p1Critical paththeme-reliabilityTheme: Reliabilitytype-epicParent epic issue (groups child sub-issues)type-featureNew functionality
Description
Summary
The current WebSocket broadcast in main.py uses in-process iteration with bare except: pass error handling. At scale (30+ agents, 50+ WebSocket connections), clients silently miss critical events — collaboration updates, health alerts, execution status changes — with no way to recover missed messages on reconnect.
Solution
Replace the in-process broadcast with Redis Streams as the event bus. Redis is already running. Streams provide:
- Persistent event log with configurable retention (e.g., last 1000 events or 1 hour)
- Replay on reconnect via
XRANGE— clients that disconnect and reconnect get missed events - Consumer groups for at-least-once delivery semantics
- Built-in backpressure via
BLOCKparameter onXREAD
Scope
- Replace
ConnectionManager.broadcast()with Redis Stream publish (XADD) - Each WebSocket connection reads from Redis Stream (
XREAD BLOCK) - Track per-client last-seen event ID; on reconnect, replay from that point
- Add stream trimming (MAXLEN ~10000 or time-based) to prevent unbounded growth
- Replace
FilteredWebSocketManagerbroadcast with stream consumer that filters by user permissions - Remove
except: passpattern — errors now tracked per-client with eviction after N failures
Acceptance Criteria
- All real-time events (agent_activity, agent_collaboration, process events, health) flow through Redis Streams
- WebSocket clients that disconnect and reconnect receive missed events (up to retention window)
- Failed sends to a client are logged and client is evicted after 3 consecutive failures
- Stream auto-trims to prevent unbounded Redis memory growth
- Existing WebSocket event format unchanged (backward compatible for frontend)
- ~100 lines to replace ConnectionManager, zero new infrastructure
Key Files
src/backend/main.py— replace ConnectionManager and FilteredWebSocketManagersrc/backend/services/activity_service.py— publish to stream instead of direct broadcastsrc/frontend/src/utils/websocket.js— send last-event-ID on reconnect
Dependencies
None — Redis already running.
Metadata
Metadata
Assignees
Labels
complexity-mediumComplexity: medium (board points 5-8)priority-p1Critical paththeme-reliabilityTheme: Reliabilitytype-epicParent epic issue (groups child sub-issues)type-featureNew functionality
Activity
vybe commentedon Apr 20, 2026
Promoted to next priority (2026-04-20)
Per orchestration simplification re-plan — this is the keystone that unlocks Tier 2.5:
See
docs/planning/ORCHESTRATION_RELIABILITY_2026-04.md— Tier 2.5.Scope reminder
XADD/XREADwith reconnect replaylastEventIdsupportMAXLEN ~10000After landing
Gate CLEANUP-COLLAPSE on "#306 in prod ≥2 weeks, zero orphan recoveries observed."
docs(architecture): document Redis Streams WebSocket transport (#306)
feat: Redis Streams event bus for WebSocket delivery (RELIABILITY-003) (
feat(observability): event-bus soak counters for #306 (#439)
docs(announcements): weekly update 2026-04-21
docs(planning): orchestration reliability — Sprint D / #306 shipped, #…
docs(planning): #408 dissolution gated on #428, not #306 (re-audit) (#…
docs(planning): mark #291 (WEBHOOK-001) shipped, Sprint C now 5/5
refactor(capacity): consolidate three queue/slot primitives into Capa…
Release: v0.5.0 (#608)
refactor(main): lifespan is an orchestrator, not a 580-line procedure (…
docs(pull): one entry point for the pull migration — delete five supe…
Release: v0.9.5 (#2872)