Repository navigation
Description
Problem
Live execution output in ExecutionDetail.vue gets stuck showing "Waiting for execution output..." spinner indefinitely. The SSE streaming mechanism has a race condition and lacks fallback recovery.
Root Cause Analysis
Race Condition (async mode)
- Backend creates execution record with
status="running"and spawns background task viaasyncio.create_task(_execute_task_background(...)) - Backend returns
execution_idimmediately to frontend - Frontend navigates to
/executions/{id}, seesstatus="running", starts SSE streaming - Frontend SSE fetch → backend proxies to
http://agent-{name}:8000/api/executions/{id}/stream - But the background task may not have delivered
/api/taskto the agent yet, or the agent hasn't started the subprocess and registered it in the process registry - Agent returns 404 → backend proxy sends error + stream_end → frontend calls
handleStreamEnd()→ setsisStreaming=false→ loads execution (still "running") and log (empty) → no further action
No Retry/Polling Fallback
After handleStreamEnd(), there is no mechanism to:
- Retry streaming connection
- Poll for execution status changes
- Re-initiate streaming when the agent catches up
Proxy Hang Scenario
If the agent container is slow/unresponsive (not 404, just hanging), httpx.AsyncClient(timeout=None) blocks indefinitely. The backend proxy has no connect timeout. No keepalive is sent from the proxy layer (keepalives only exist in the agent-side generator). Frontend fetch sits waiting forever → permanent "Waiting for execution output..." spinner.
Error Swallowing
ExecutionDetail.vue:547-549 — when receiving {"type": "error"} from the stream, it only logs to console and continues. No user-visible feedback.
Affected Files
| Component | File |
|---|---|
| Frontend streaming UI | src/frontend/src/views/ExecutionDetail.vue (lines 293-295, 500-579) |
| Backend SSE proxy | src/backend/routers/chat.py (lines 1378-1439) |
| Agent SSE endpoint | docker/base-image/agent_server/routers/chat.py (lines 300-374) |
| Process registry | docker/base-image/agent_server/services/process_registry.py |
Proposed Fixes
1. Add polling fallback when stream ends prematurely
In handleStreamEnd(), if execution status is still "running", start a setInterval that:
- Polls execution status every 5s
- Retries streaming connection when execution is confirmed running on the agent
- Stops when execution completes or fails
2. Add connect timeout to backend SSE proxy
Replace httpx.AsyncClient(timeout=None) with a proper timeout config:
timeout = httpx.Timeout(connect=10.0, read=None, write=None, pool=None)
async with httpx.AsyncClient(timeout=timeout) as client:3. Add keepalive in backend proxy
Send keepalive comments from the backend proxy layer if no data received from agent within 30s, preventing frontend fetch from timing out.
4. Surface stream errors to user
Instead of just console.error, show a toast/notification when stream errors occur, and provide a "Retry" button.
Activity
fix: Live execution output stuck on 'Waiting for execution output...' (…
Merge pull request #127 from Abilityai/feature/68-live-execution-output
feat(brain-orb): close the write→graph refresh loop + visible integra…
Merge pull request #1407 from Abilityai/feature/61-brain-orb-actions