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 deducted2. plan.created → DAG plan generated with ordered steps3. step.started → Step execution started in Celery worker4. tool.started → Agent invoked a tool (search, scrape, query)5. tool.completed → Tool returned output6. token → Incremental text stream7. approval.required → (Optional) Guarded action requires confirmation8. step.completed → Step finished9. done → Final result payload, run completedEvent 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" }}