Skip to content

SSE Stream Events

When stream: true is set, the API responds with a Server-Sent Events (SSE) stream adhering to the W3C EventSource standard.

Event Sequence Flow

1. run.started → Run initialized, pre-flight credits deducted
2. plan.created → DAG plan generated with ordered steps
3. step.started → Step execution started in Celery worker
4. tool.started → Agent invoked a tool (search, scrape, query)
5. tool.completed → Tool returned output
6. token → Incremental text stream
7. approval.required → (Optional) Guarded action requires confirmation
8. step.completed → Step finished
9. done → Final result payload, run completed

Event Payloads

run.started

{
"event": "run.started",
"data": {
"run_id": "run_01J8K3M9N2P4Q5R6S7T8U9V0",
"workspace_id": "ws_12345",
"estimated_credits": 25,
"created_at": "2024-10-15T14:32:01.120Z"
}
}

approval.required

{
"event": "approval.required",
"data": {
"run_id": "run_01J8K3M9N2P4Q5R6S7T8U9V0",
"step_id": "step_abc123",
"action": "EMAIL_SEND",
"preview": {
"to": "investors@acme.com",
"subject": "Q3 Financials"
},
"expires_at": "2024-10-16T14:32:01.120Z"
}
}

token

{
"event": "token",
"data": {
"delta": " revenue increased by 14% MoM."
}
}

done

{
"event": "done",
"data": {
"run_id": "run_01J8K3M9N2P4Q5R6S7T8U9V0",
"total_credits_used": 20,
"duration_ms": 3420,
"status": "COMPLETED"
}
}