Python: fix: concurrent_agents sample incorrectly treats output as list[Message] - #6548
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the concurrent agents orchestration sample to treat each orchestration result as a structured AgentResponse instead of a loosely typed message list.
Changes:
- Import
AgentResponseand remove the previousAny-based casting. - Add a runtime type check for
AgentResponsebefore printing results. - Iterate over
output.messagesrather than assumingoutputislist[Message].
|
Benke Qu (@benke520) there are merge conflicts and open comments, please have a look! |
…but it is AgentResponse The default ConcurrentBuilder aggregator yields AgentResponse, not list[Message]. The sample incorrectly cast the output to list[Message] and iterated it directly. Fix by checking isinstance(output, AgentResponse) and iterating output.messages instead.
a998c08 to
9895c53
Compare
Thanks Eduard van Valkenburg (@eavanvalkenburg) — both addressed! Merge conflicts resolved (rebased onto latest main) and replied to the Copilot review comment. Also added a warning print for unexpected output types to avoid silent skipping. |
1 similar comment
Thanks Eduard van Valkenburg (@eavanvalkenburg) — both addressed! Merge conflicts resolved (rebased onto latest main) and replied to the Copilot review comment. Also added a warning print for unexpected output types to avoid silent skipping. |
…ample output - Remove unused Message import - Update docstring: default aggregator yields AgentResponse objects, not list[Message] - Fix sample output: remove user prompt entry (aggregator returns only assistant messages) - Renumber sample output entries (researcher=01, marketer=02, legal=03)
Problem
The
concurrent_agents.pysample treatsget_outputs()results aslist[Message]directly:However, at runtime the default
ConcurrentBuilderaggregator yieldsAgentResponseobjects, notlist[Message]. This causes incorrect iteration behavior.Verification
Fix
Check
isinstance(output, AgentResponse)and iterateoutput.messagesinstead of treating the output as a raw list.Testing
Ran the sample locally with
agent-frameworkv1.8.0 and confirmed the output is correctly printed with the fix.