File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -747,7 +747,7 @@ async def test_run_stream_in_flow(allow_model_requests: None) -> None:
747747 @flow (name = 'test_run_stream_in_flow' )
748748 async def run_stream_workflow ():
749749 async with simple_prefect_agent .run_stream ('What is the capital of Mexico?' ) as result :
750- return await result .get_output ()
750+ return await result .get_output () # pragma: no cover
751751
752752 with flow_raises (
753753 UserError ,
@@ -759,6 +759,25 @@ async def run_stream_workflow():
759759 await run_stream_workflow ()
760760
761761
762+ async def test_run_stream_events_in_flow (allow_model_requests : None ) -> None :
763+ """Test that run_stream_events errors when used inside a Prefect flow."""
764+
765+ @flow (name = 'test_run_stream_events_in_flow' )
766+ async def run_stream_events_workflow ():
767+ return [
768+ event async for event in simple_prefect_agent .run_stream_events ('What is the capital of Mexico?' )
769+ ] # pragma: no cover
770+
771+ with flow_raises (
772+ UserError ,
773+ snapshot (
774+ '`agent.run_stream_events()` cannot be used inside a Prefect flow. '
775+ 'Set an `event_stream_handler` on the agent and use `agent.run()` instead.'
776+ ),
777+ ):
778+ await run_stream_events_workflow ()
779+
780+
762781async def test_iter_in_flow (allow_model_requests : None ) -> None :
763782 """Test that iter works inside a Prefect flow."""
764783
You can’t perform that action at this time.
0 commit comments