[P0] Real-Time Communication Layer for Agentic Investigations #92

Closed
opened 2026-06-10 03:32:30 +00:00 by Mark · 0 comments
Owner

Problem

The frontend currently polls the backend every 5 seconds for investigation updates. This is inefficient and does not provide real-time visibility into the agent thought process and tool calls during autonomous investigations.

Proposed Solution

Implement Server-Sent Events (SSE) for streaming investigation updates from backend to frontend:

Backend Changes

  1. Create SSE endpoint: POST /api/investigations/{run_id}/stream
  2. Emit events during investigation: agent_thought, tool_call, entity_discovered, evidence_gathered, step_complete, error
  3. Create WebSocket manager for bidirectional communication (pause/resume/cancel/approve/reject)
  4. Modify orchestrator_v3_llm.py to emit events in real-time

Files to Create/Modify

  • backend/app/services/investigations/stream_manager.py (new)
  • backend/app/services/investigations/orchestrator_v3_llm.py - add event emission
  • backend/app/main.py - add SSE routes

Frontend Changes

  1. Create useInvestigationStream hook for SSE client
  2. Replace polling with WebSocket/SSE connection in InvestigationDetail
  3. Add real-time agent thought display

Files to Create/Modify

  • frontend/src/hooks/useInvestigationStream.js (new)
  • frontend/src/components/InvestigationDetail.jsx - integrate SSE

Acceptance Criteria

  • SSE endpoint streams investigation events in real-time
  • Frontend displays agent thoughts as they happen
  • User can pause/resume investigation from UI
  • User can approve/reject discovered entities mid-investigation
  • WebSocket connection handles reconnection gracefully

Effort

Medium - 1-2 weeks

## Problem The frontend currently polls the backend every 5 seconds for investigation updates. This is inefficient and does not provide real-time visibility into the agent thought process and tool calls during autonomous investigations. ## Proposed Solution Implement Server-Sent Events (SSE) for streaming investigation updates from backend to frontend: ### Backend Changes 1. Create SSE endpoint: POST /api/investigations/{run_id}/stream 2. Emit events during investigation: agent_thought, tool_call, entity_discovered, evidence_gathered, step_complete, error 3. Create WebSocket manager for bidirectional communication (pause/resume/cancel/approve/reject) 4. Modify orchestrator_v3_llm.py to emit events in real-time ### Files to Create/Modify - backend/app/services/investigations/stream_manager.py (new) - backend/app/services/investigations/orchestrator_v3_llm.py - add event emission - backend/app/main.py - add SSE routes ### Frontend Changes 1. Create useInvestigationStream hook for SSE client 2. Replace polling with WebSocket/SSE connection in InvestigationDetail 3. Add real-time agent thought display ### Files to Create/Modify - frontend/src/hooks/useInvestigationStream.js (new) - frontend/src/components/InvestigationDetail.jsx - integrate SSE ## Acceptance Criteria - SSE endpoint streams investigation events in real-time - Frontend displays agent thoughts as they happen - User can pause/resume investigation from UI - User can approve/reject discovered entities mid-investigation - WebSocket connection handles reconnection gracefully ## Effort Medium - 1-2 weeks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/osint-hub#92
No description provided.