SDK streaming
Python and TypeScript SDKs expose token and step events through streaming iterators while the Rust engine runs in-process. Traces record StreamChunkReceived and TokenEmitted with byte and token counts only (trace data policy). Server-side SSE at GET /v1/runs/{id}/events is not implemented (streaming deferred); use SDK streaming for in-process UX or poll trace from HTTP clients.
Enable streaming in exec_config
When disabled, the SDK returns the full step output at completion with no incremental token events.
Python passes exec config via run options or workflow defaults depending on your wrapper; TypeScript accepts { stream: { enabled: true } } on runStream.
Python: run_stream
run_stream is async; iterate with async for:
See examples/streaming/chat_stream.py. Stub agents work without LLM API keys.
Stream event types (Python)
| event.type | Fields | Use |
|---|---|---|
token | text (delta at SDK layer) | Incremental UI rendering |
step_start | step_id | Progress indicator |
step_complete | step_id, duration_ms | Step boundary |
| other | varies | Diagnostics |
SDK token text is available to your application code during the run. Persisted traces and HTTP trace exports do not store raw token strings.
TypeScript: runStream
See examples/streaming/chat_stream.ts.
Trace events during streaming
After the run, inspect metadata-only trace events:
Use these events for dashboards and latency analysis, not for reconstructing full completions from trace storage alone.
Blocking run vs stream
| API | When to use |
|---|---|
workflow.run() | Batch jobs, tests, simple scripts |
workflow.run_stream() / runStream | Chat UIs, progressive rendering in Node or Python services |
Both paths share the same engine and trace data policy trace rules.
server SSE deferred
Remote clients cannot open an SSE channel to arcflow-server today. HTTP integrations should poll GET /v1/runs/{id} or GET /v1/runs/{id}/trace. Browser apps use Relay trace polling; see streaming in the browser.
Related pages
- Streaming in the browser for Relay polling pattern
- Execution traces for reading traces after a stream completes
- Maturity and known gaps for server streaming status