Skip to content

Commit 877a792

Browse files
committed
Test streamed sequential workflow agent keeps one message per agent
1 parent 76f3dcb commit 877a792

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎python/packages/orchestrations/tests/test_sequential.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,25 @@ async def test_sequential_as_agent_returns_only_last_agent_response() -> None:
193193
assert "hello as_agent" not in combined
194194

195195

196+
async def test_sequential_as_agent_streaming_keeps_one_message_per_agent() -> None:
197+
"""Streaming `workflow.as_agent()` with `output_from="all"` keeps each agent's reply as its own message,
198+
the same messages a non-streaming run returns."""
199+
200+
def build_agent() -> Any:
201+
participants = [_EchoAgent(id="agent1", name="A1"), _EchoAgent(id="agent2", name="A2")]
202+
return SequentialBuilder(participants=participants, output_from="all").build().as_agent()
203+
204+
response = await build_agent().run("hello")
205+
stream = build_agent().run("hello", stream=True)
206+
async for _ in stream:
207+
pass
208+
streamed = await stream.get_final_response()
209+
210+
assert [m.text for m in response.messages] == ["A1 reply", "A2 reply"]
211+
assert [m.text for m in streamed.messages] == ["A1 reply", "A2 reply"]
212+
assert [m.author_name for m in streamed.messages] == ["A1", "A2"]
213+
214+
196215
async def test_sequential_with_custom_executor_summary() -> None:
197216
"""A custom-executor terminator yields its own AgentResponse — that becomes the workflow output.
198217

0 commit comments

Comments
 (0)