From 2abc9c8657aa7a9098310112e97736c19734917b Mon Sep 17 00:00:00 2001 From: Bright Oparaji Date: Sat, 5 Sep 2026 12:39:56 +0100 Subject: [PATCH 1/4] docs(streaming): fix streaming output docstring examples CrewStreamingOutput's example called crew.kickoff() without setting stream=True on the Crew, so the snippet returned a CrewOutput and did not stream anything. FlowStreamingOutput's example called flow.kickoff_streaming() and flow.kickoff_streaming_async(); neither method exists. Flow-level streaming is exposed through Flow.kickoff with stream=True and returns a StreamSession, not a FlowStreamingOutput. Refs #7285 --- lib/crewai/src/crewai/types/streaming.py | 27 +++++++++--------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/crewai/src/crewai/types/streaming.py b/lib/crewai/src/crewai/types/streaming.py index 5115afa73b..a55781aa31 100644 --- a/lib/crewai/src/crewai/types/streaming.py +++ b/lib/crewai/src/crewai/types/streaming.py @@ -504,13 +504,15 @@ class CrewStreamingOutput(StreamingOutputBase["CrewOutput"]): Example: ```python - # Single crew + # Single crew — the crew must be constructed with stream=True + crew = Crew(agents=[...], tasks=[...], stream=True) streaming = crew.kickoff(inputs={"topic": "AI"}) for chunk in streaming: print(chunk.content, end="", flush=True) result = streaming.result - # Multiple crews (kickoff_for_each_async) + # Multiple crews (kickoff_for_each_async) — also requires stream=True + crew = Crew(agents=[...], tasks=[...], stream=True) streaming = await crew.kickoff_for_each_async( [{"topic": "AI"}, {"topic": "ML"}] ) @@ -580,22 +582,13 @@ class FlowStreamingOutput(StreamingOutputBase[Any]): """Streaming output wrapper for flow execution. Provides both sync and async iteration over stream chunks, - with access to the final flow output via the .result property. + with access to the final flow output via the ``.result`` property. - Example: - ```python - # Sync usage - streaming = flow.kickoff_streaming() - for chunk in streaming: - print(chunk.content, end="", flush=True) - result = streaming.result - - # Async usage - streaming = await flow.kickoff_streaming_async() - async for chunk in streaming: - print(chunk.content, end="", flush=True) - result = streaming.result - ``` + Note: + Flow-level streaming is exposed to users through + :class:`StreamSession` (see ``Flow.kickoff`` with ``stream=True``). + ``FlowStreamingOutput`` is retained for consumers that build a + streaming wrapper directly from an existing iterator. """ def _set_result(self, result: Any) -> None: From d781e71b1e4d1cabdf52c41470c6f2e59bc3dd7b Mon Sep 17 00:00:00 2001 From: Bright Oparaji Date: Sat, 5 Sep 2026 12:52:51 +0100 Subject: [PATCH 2/4] docs(streaming): clarify Flow.kickoff does not take stream param Flow.kickoff() has no stream parameter; the runtime returns a StreamSession when self.stream is True. Reword the FlowStreamingOutput note so callers know to configure the Flow with stream=True before calling kickoff(). Addresses CodeRabbit review on #7286. --- lib/crewai/src/crewai/types/streaming.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/crewai/src/crewai/types/streaming.py b/lib/crewai/src/crewai/types/streaming.py index a55781aa31..76f0734219 100644 --- a/lib/crewai/src/crewai/types/streaming.py +++ b/lib/crewai/src/crewai/types/streaming.py @@ -586,9 +586,10 @@ class FlowStreamingOutput(StreamingOutputBase[Any]): Note: Flow-level streaming is exposed to users through - :class:`StreamSession` (see ``Flow.kickoff`` with ``stream=True``). - ``FlowStreamingOutput`` is retained for consumers that build a - streaming wrapper directly from an existing iterator. + :class:`StreamSession`; configure the Flow with ``stream=True`` + before calling ``Flow.kickoff()``. ``FlowStreamingOutput`` is + retained for consumers that build a streaming wrapper directly + from an existing iterator. """ def _set_result(self, result: Any) -> None: From b80a57a22548d8e22ab733edbbc153de94f239a6 Mon Sep 17 00:00:00 2001 From: Bright Oparaji Date: Mon, 7 Sep 2026 10:00:40 +0100 Subject: [PATCH 3/4] docs(streaming): restore FlowStreamingOutput example Add back an Example block showing valid usage of FlowStreamingOutput. The class is only ever constructed directly with a chunk-producing iterator (see lib/crewai/tests/test_streaming.py), so the example mirrors that pattern instead of the original snippet that referenced non-existent Flow.kickoff_streaming methods. Addresses review feedback on #7286. --- lib/crewai/src/crewai/types/streaming.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/crewai/src/crewai/types/streaming.py b/lib/crewai/src/crewai/types/streaming.py index 76f0734219..e7289cc738 100644 --- a/lib/crewai/src/crewai/types/streaming.py +++ b/lib/crewai/src/crewai/types/streaming.py @@ -584,6 +584,23 @@ class FlowStreamingOutput(StreamingOutputBase[Any]): Provides both sync and async iteration over stream chunks, with access to the final flow output via the ``.result`` property. + Example: + ```python + # FlowStreamingOutput wraps a chunk-producing iterator directly. + # Consumers use it to expose a custom flow-execution generator + # through the same iteration + .result API as CrewStreamingOutput. + streaming = FlowStreamingOutput(sync_iterator=chunk_generator()) + for chunk in streaming: + print(chunk.content, end="", flush=True) + result = streaming.result + + # Async variant: + streaming = FlowStreamingOutput(async_iterator=async_chunk_generator()) + async for chunk in streaming: + print(chunk.content, end="", flush=True) + result = streaming.result + ``` + Note: Flow-level streaming is exposed to users through :class:`StreamSession`; configure the Flow with ``stream=True`` From 454b9ebe569c574fc9e6762020930f982697c20e Mon Sep 17 00:00:00 2001 From: Bright Oparaji Date: Mon, 7 Sep 2026 11:08:22 +0100 Subject: [PATCH 4/4] docs(streaming): swap FlowStreamingOutput example for public Flow streaming path Replace the test-only FlowStreamingOutput(sync_iterator=...) example with the actual public flow-streaming path: Flow.stream=True followed by kickoff() / kickoff_async(), which return StreamSession / AsyncStreamSession. The example is labeled explicitly to make clear that Flow.kickoff() does not return a FlowStreamingOutput, and points readers at the streaming-flow-execution guide. Addresses review feedback on #7286. --- lib/crewai/src/crewai/types/streaming.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/crewai/src/crewai/types/streaming.py b/lib/crewai/src/crewai/types/streaming.py index e7289cc738..a46c2886e1 100644 --- a/lib/crewai/src/crewai/types/streaming.py +++ b/lib/crewai/src/crewai/types/streaming.py @@ -586,18 +586,22 @@ class FlowStreamingOutput(StreamingOutputBase[Any]): Example: ```python - # FlowStreamingOutput wraps a chunk-producing iterator directly. - # Consumers use it to expose a custom flow-execution generator - # through the same iteration + .result API as CrewStreamingOutput. - streaming = FlowStreamingOutput(sync_iterator=chunk_generator()) - for chunk in streaming: - print(chunk.content, end="", flush=True) + # Flow-level streaming returns a StreamSession from Flow.kickoff() — + # NOT a FlowStreamingOutput. See + # docs/edge/en/learn/streaming-flow-execution.mdx for the full guide. + flow = MyFlow() + flow.stream = True + streaming = flow.kickoff() # -> StreamSession + for frame in streaming: + print(frame.content, end="", flush=True) result = streaming.result # Async variant: - streaming = FlowStreamingOutput(async_iterator=async_chunk_generator()) - async for chunk in streaming: - print(chunk.content, end="", flush=True) + flow = MyFlow() + flow.stream = True + streaming = await flow.kickoff_async() # -> AsyncStreamSession + async for frame in streaming: + print(frame.content, end="", flush=True) result = streaming.result ```