This sample demonstrates streaming a durable workflow's progress from a
standalone Durable Task worker — no Azure Functions required. It is the
streaming counterpart to 08_workflow.
- The async
DurableWorkflowClientAPI:run_workflow(input, wait=False)— start a workflow without blocking and get its instance id.stream_workflow(instance_id)— an async iterator that yields typedWorkflowEventobjects (executor_invoked/executor_completed/output/ ...) as the workflow progresses, ending when it reaches a terminal state. Each event'sdatais already reconstructed into its original typed object, so the client never deserializes anything by hand.await_workflow_output(instance_id)— read the final reconstructed output.
- Brokerless streaming. The orchestrator publishes accumulated events to the orchestration custom status after each superstep (only on live execution, not replay), and the client streams them by polling. No Redis or other message broker is required.
- Per-executor granularity. Events fire per executor and per yielded output,
not at the token level. Non-agent executors carry their captured event data;
agent executors surface coarse
executor_invoked/executor_completedlifecycle events. (Token-level streaming through a durable boundary would require an external broker.)
See the README.md in the parent directory for environment setup.
This sample uses Azure AI Foundry credentials:
FOUNDRY_PROJECT_ENDPOINTFOUNDRY_MODEL
It also needs a Durable Task Scheduler. For local development, start the
emulator (defaults to http://localhost:8080):
docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latestStart the worker in one terminal:
cd samples/04-hosting/durabletask/10_workflow_streaming
python worker.pyIn a second terminal, run the client:
python client.pyThe workflow is a linear pipeline — WriterAgent → ReviewerAgent → publish —
so the client prints the progress events as each executor runs, for example:
Streaming workflow events:
[executor_invoked] WriterAgent
[executor_completed] WriterAgent
[executor_invoked] ReviewerAgent
[executor_completed] ReviewerAgent
[executor_invoked] publish
[executor_completed] publish
[output] from publish: Published: ...
Final output: Published: ...