Question/Suggestion: Avoid emitting StopEvent through stream_events in v2? #26

Open
opened 2026-02-16 02:16:11 -05:00 by yindo · 2 comments
Owner

Originally created by @enrico-stauss on GitHub (Dec 2, 2025).

Hi,

I couldn't find prior discussions about it, so I just wanted to understand how you feel about the fact that the current implementation emits the StopEvent twice (once in stream_events and once in await handler). While this is not really an issue since I can just break out of the loop once I receive the StopEvent, I find it unintuitive that it acts as both a regular streamed event and a result.

I could imagine leveraging the result await handler to get some extra information from the workflow, maybe something that can be accumulated using callbacks or so during the workflow.run? Or alternatively, the stream_events could just omit the StopEvent? A default parameter specifying the event types that shall be skipped during streaming?

As I said, this is not really a specific question but rather thought for discussion and since I saw that you already started planning v2, I thought now would be a good time.

Cheers :)

Originally created by @enrico-stauss on GitHub (Dec 2, 2025). Hi, I couldn't find prior discussions about it, so I just wanted to understand how you feel about the fact that the current implementation emits the `StopEvent` twice (once in `stream_events` and once in `await handler`). While this is not really an issue since I can just break out of the loop once I receive the `StopEvent`, I find it unintuitive that it acts as both a regular streamed event and a result. I could imagine leveraging the `result await handler` to get some extra information from the workflow, maybe something that can be accumulated using callbacks or so during the `workflow.run`? Or alternatively, the stream_events could just omit the `StopEvent`? A default parameter specifying the event types that shall be skipped during streaming? As I said, this is not really a specific question but rather thought for discussion and since I saw that you already started planning v2, I thought now would be a good time. Cheers :)
Author
Owner

@adrianlyjak commented on GitHub (Jan 6, 2026):

One observeration: There's precedent for include_internal_events when requesting stream_events, it might make sense to have some other configuration there for e.g. exclude_stop_events for common scenarios. That can be a non-breaking change

@adrianlyjak commented on GitHub (Jan 6, 2026): One observeration: There's precedent for `include_internal_events` when requesting `stream_events`, it might make sense to have some other configuration there for e.g. `exclude_stop_events` for common scenarios. That can be a non-breaking change
Author
Owner

@adrianlyjak commented on GitHub (Jan 6, 2026):

Another observation: It's helpful for the workflow server to have stop events in its stream. Unlike the python async iterator, the SSE stream (at least via EventSource doesn't natively have a way to detect "the stream is done". EventSource treats a normal http disconnect as a lost connection, and attempts a reconnect. So It's helpful to have the stop event as that indicator that the stream is all done.

@adrianlyjak commented on GitHub (Jan 6, 2026): Another observation: It's helpful for the workflow server to have stop events in its stream. Unlike the python async iterator, the SSE stream (at least via [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) doesn't natively have a way to detect "the stream is done". `EventSource` treats a normal http disconnect as a lost connection, and attempts a reconnect. So It's helpful to have the stop event as that indicator that the stream is all done.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#26