Add SSE streaming for AI responses #3

Open
opened 2026-03-18 22:01:00 +00:00 by hermes · 0 comments
Collaborator

Context

Currently the agent returns complete text after execution finishes. For a good
Workshop UX, responses should stream token-by-token as Claude generates them.

Requirements

  • Add SSE (Server-Sent Events) streaming to the work execution phase
  • When a job enters executing state, stream partial results via SSE
  • Endpoint: GET /api/jobs/:id/stream (returns text/event-stream)
  • Also support streaming for Session Mode 2 requests
  • Use Anthropic's streaming API (stream: true on messages.create)

Event Format

data: {"type": "token", "content": "The"}
data: {"type": "token", "content": " Lightning"}
data: {"type": "token", "content": " Network"}
data: {"type": "done", "result": "The Lightning Network is...", "inputTokens": 50, "outputTokens": 120}

Acceptance Criteria

  • SSE endpoint works for Mode 1 jobs
  • SSE endpoint works for Mode 2 session requests
  • Tokens appear within 200ms of generation
  • Final event includes complete result + token counts
  • Connection properly closes on completion or error
  • Backpressure handling (slow clients)

References

  • Parent epic: #{epic_num}
## Context Currently the agent returns complete text after execution finishes. For a good Workshop UX, responses should stream token-by-token as Claude generates them. ## Requirements - Add SSE (Server-Sent Events) streaming to the work execution phase - When a job enters `executing` state, stream partial results via SSE - Endpoint: `GET /api/jobs/:id/stream` (returns `text/event-stream`) - Also support streaming for Session Mode 2 requests - Use Anthropic's streaming API (`stream: true` on messages.create) ## Event Format ``` data: {"type": "token", "content": "The"} data: {"type": "token", "content": " Lightning"} data: {"type": "token", "content": " Network"} data: {"type": "done", "result": "The Lightning Network is...", "inputTokens": 50, "outputTokens": 120} ``` ## Acceptance Criteria - [ ] SSE endpoint works for Mode 1 jobs - [ ] SSE endpoint works for Mode 2 session requests - [ ] Tokens appear within 200ms of generation - [ ] Final event includes complete result + token counts - [ ] Connection properly closes on completion or error - [ ] Backpressure handling (slow clients) ## References - Parent epic: #{epic_num}
hermes added the apienhancementreplit labels 2026-03-18 22:01:00 +00:00
replit self-assigned this 2026-03-18 22:02:21 +00:00
This repo is archived. You cannot comment on issues.