Skip to content

Python: fix: concurrent_agents sample incorrectly treats output as list[Message] - #6548

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 4 commits into
microsoft:mainfrom
benke520:fix/concurrent-sample-output-type
Jul 17, 2026
Merged

Python: fix: concurrent_agents sample incorrectly treats output as list[Message]#6548
Eduard van Valkenburg (eavanvalkenburg) merged 4 commits into
microsoft:mainfrom
benke520:fix/concurrent-sample-output-type

Conversation

@benke520

Copy link
Copy Markdown
Member

Problem

The concurrent_agents.py sample treats get_outputs() results as list[Message] directly:

for output in outputs:
    messages: list[Message] | Any = output
    for i, msg in enumerate(messages, start=1):

However, at runtime the default ConcurrentBuilder aggregator yields AgentResponse objects, not list[Message]. This causes incorrect iteration behavior.

Verification

outputs = events.get_outputs()
for output in outputs:
    print(type(output).__name__)  # prints "AgentResponse", not "list"

Fix

Check isinstance(output, AgentResponse) and iterate output.messages instead of treating the output as a raw list.

Testing

Ran the sample locally with agent-framework v1.8.0 and confirmed the output is correctly printed with the fix.

Copilot AI review requested due to automatic review settings June 16, 2026 17:04
@moonbox3 Evan Mattson (moonbox3) added the python Usage: [Issues, PRs], Target: Python label Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentResponse and remove the previous Any-based casting.
  • Add a runtime type check for AgentResponse before printing results.
  • Iterate over output.messages rather than assuming output is list[Message].

Comment thread python/samples/03-workflows/orchestrations/concurrent_agents.py
@eavanvalkenburg

Copy link
Copy Markdown
Member

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.
@benke520
Benke Qu (benke520) force-pushed the fix/concurrent-sample-output-type branch from a998c08 to 9895c53 Compare July 8, 2026 15:01
@benke520

Copy link
Copy Markdown
Member Author

Benke Qu (@benke520) there are merge conflicts and open comments, please have a look!

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
@benke520

Copy link
Copy Markdown
Member Author

Benke Qu (@benke520) there are merge conflicts and open comments, please have a look!

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.

Comment thread python/samples/03-workflows/orchestrations/concurrent_agents.py Outdated
…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)
Merged via the queue into microsoft:main with commit cad8192 Jul 17, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants