Skip to content

Python: Read orchestration outputs as agent responses in tool approval samples - #10084

Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-orchestration-sample-outputs
Draft

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-orchestration-sample-outputs

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

Four orchestration samples treat workflow output events as a list[Message]. Sequential, group chat and concurrent orchestrations emit AgentResponseUpdate values while streaming and an AgentResponse otherwise, so each sample crashes when the output arrives. In the three tool-approval samples that happens after the approval has already gone through:

Sample Error on main
tool-approval/sequential_builder_tool_approval.py TypeError: 'AgentResponseUpdate' object is not iterable
tool-approval/group_chat_builder_tool_approval.py TypeError: 'AgentResponseUpdate' object is not iterable
tool-approval/concurrent_builder_tool_approval.py TypeError: 'AgentResponse' object is not iterable (after the "not a list of Message" check is skipped by its and)
orchestrations/concurrent_custom_agent_executors.py TypeError: 'AgentResponse' object is not iterable

Description & Review Guide

  • What are the major changes? Samples only:
    • The sequential and group chat approval samples collect the streamed AgentResponseUpdate outputs and print the summary from AgentResponse.from_updates(...), skipping messages with no text, such as the tool call.
    • The concurrent samples read .messages from the AgentResponse, as concurrent_agents.py already does.
  • What is the impact of these changes? The samples run to completion. Unused imports are removed.
  • What do you want reviewers to focus on? For the sequential sample, the streamed output is the final participant's response. The summary now prints that response, not the whole conversation the old comment described.

Verification: I replaced the Foundry client with a scripted stub that first calls the approval-required tool and answers once the result comes back. Each sample then goes through the approval request, the simulated approval and the final summary, for example Workflow summary: [DatabaseAgent]: Stub final answer. The unmodified files crash with the errors above under the same stub. Ruff and the repo's pyrightconfig.samples.json (with --warnings) are clean.

Related Issue

N/A - trivial change: samples are updated to the output types the orchestrations already emit.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the crashes by running the samples against a stub client, update the output handling, re-run the approval flow, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

…l samples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 05:41
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 4, 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.

🟢 Approval recommended

No active review issues are recorded for the workflow sample response-handling updates.

No open issues 🎉

What changed in this PR

Updates four Python workflow samples to consume the response types emitted by orchestration builders, fixing crashes caused by treating outputs as message lists.

Changes:

  • Sequential and group chat approval samples combine streamed AgentResponseUpdate values and print messages containing text.
  • Concurrent samples read messages from AgentResponse.messages.
  • Imports and output comments are updated to match the corrected handling.
File Description
python/​samples/​03-workflows/​tool-approval/​sequential_builder_tool_approval.py Builds the summary from the final participant’s streamed response.
python/​samples/​03-workflows/​tool-approval/​group_chat_builder_tool_approval.py Combines streamed response updates and skips messages without text.
python/​samples/​03-workflows/​tool-approval/​concurrent_builder_tool_approval.py Validates AgentResponse output and reads its messages.
python/​samples/​03-workflows/​orchestrations/​concurrent_custom_agent_executors.py Reads aggregated messages from the workflow’s AgentResponse.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — eea53fbf Deployed Nov 4, 2026 by 1aifanatic via team_check #8675
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.

2 participants