Commit 339b9c3
Python: [BREAKING] Standardize orchestration terminal outputs as AgentResponse (#5301)
* Fix orchestration outputs so as_agent() returns the final answer only. Align other orchestration outputs
* Fix orchestration output issues from review comments
1. Sample cleanup: Remove commented-out FoundryChatClient block and update
prerequisites to reference OPENAI_CHAT_MODEL_ID instead of FOUNDRY_* vars.
2. Sequential approval output: Change _EndWithConversation.end_with_agent_executor_response
from a no-op sink to yield response.agent_response. When the last participant is
AgentApprovalExecutor (via with_request_info), _EndWithConversation is the output
executor so the yield produces the terminal answer. When the last participant is a
regular AgentExecutor, _EndWithConversation is not in output_executors so the yield
is silently filtered out.
3. Forward data events through WorkflowExecutor: _process_workflow_result now also
forwards 'data' events from sub-workflows so that emit_intermediate_data=True on
AgentExecutor works correctly when wrapped in AgentApprovalExecutor.
4. Concurrent docstring: Update _AggregateAgentConversations docstring to say
'deterministic participant order' instead of 'completion order'.
5. Add test_concurrent_intermediate_outputs_emits_data_events verifying that
ConcurrentBuilder(intermediate_outputs=True) emits per-participant data events
alongside the single aggregated output event.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add tests for sequential workflow with_request_info and intermediate_outputs (#5301)
Address PR review comments 2, 3, and 5:
- Add test_sequential_request_info_last_participant_emits_output:
Verifies that when the last participant is wrapped via with_request_info()
(AgentApprovalExecutor), the workflow still emits a terminal output after
approval, exercising the _EndWithConversation.end_with_agent_executor_response
fallback path.
- Add test_sequential_request_info_with_intermediate_outputs_emits_data_events:
Verifies that emit_intermediate_data=True works correctly through
AgentApprovalExecutor wrapping—WorkflowExecutor._process_result already
forwards data events from sub-workflows, so intermediate agent responses
surface as data events in the parent workflow.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix pyright type errors from AgentResponse output refactor (#5301)
Update cast() calls in _group_chat.py and _magentic.py to use
WorkflowContext[Never, AgentResponse] instead of the old
WorkflowContext[Never, list[Message]], matching the updated method
signatures in _base_group_chat_orchestrator.py.
Fix _sequential.py _EndWithConversation.end_with_agent_executor_response
to declare WorkflowContext[Any, AgentResponse] so yield_output accepts
AgentResponse[None].
Fix _workflow_executor.py data event forwarding to handle nullable
executor_id.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix pyright reportUnknownVariableType in _agent.py (#5301)
Extract event.data into a typed local variable before the isinstance
check to avoid pyright narrowing it to AgentResponse[Unknown].
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix pyright reportMissingImports for orjson in file history samples (#5301)
Add pyright: ignore[reportMissingImports] to orjson imports that are
already guarded by try/except ImportError, matching the existing pattern
used elsewhere in the samples.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #5301: review comment fixes
* Address review feedback for #5301: review comment fixes
* Revert sequential_workflow_as_agent sample to FoundryChatClient
Reverts the mistaken switch from FoundryChatClient to OpenAIChatClient
in the sequential workflow as agent sample.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address ultrareview feedback: emit_data_events rename + WorkflowAgent reasoning conversion
Layered on top of the prior review-feedback work in this branch.
Renames:
- AgentExecutor.emit_intermediate_data -> emit_data_events (mechanical
rename; orchestration semantics live at the orchestration layer, not
the general-purpose executor). Forwarded through MagenticAgentExecutor,
AgentApprovalExecutor, and all orchestration call sites.
- HandoffAgentExecutor._check_terminate_and_yield -> _should_terminate
(pure predicate; no longer yields anything). HandoffBuilder docstring
rewritten to describe the new per-agent AgentResponse output contract.
WorkflowAgent reasoning-content conversion:
- Add _rewrite_text_to_reasoning(contents) and _msg_as_reasoning(msg)
helpers; the as_agent() path now reframes text content from data events
as text_reasoning Content blocks before merging into the AgentResponse.
- Consumers iterate msg.contents and branch on content.type — same path
they already use for Claude thinking and OpenAI reasoning. No new
field on Message/AgentResponse/WorkflowEvent.
- Streaming branch constructs fresh AgentResponseUpdate instances instead
of mutating shared payloads (regression test added).
- Helper _msg_maybe_reasoning consolidates the conditional rewrite at
three call sites in the non-streaming conversion.
Tests:
- TestWorkflowAgentReasoningHelpers + TestWorkflowAgentDataEventReasoningConversion
add 9 new tests covering helpers, non-streaming, streaming, mixed content,
already-reasoning passthrough, and mutation-safety regression.
- Updated test_sequential_as_agent_with_intermediate_outputs_includes_chain
to assert text_reasoning content for intermediate agents.
* Fix pyright: widen event.data to Any to avoid partial-unknown narrowing
The streaming conversion path narrowed event.data via isinstance against
generic AgentResponse, producing AgentResponse[Unknown] and tripping
reportUnknownVariableType/reportUnknownMemberType. Binding data: Any
before the check keeps runtime behavior identical while restoring a fully
known type for downstream access.
* Clean up design
* Scope to agent output semantics only
* yield AgentResponseUpdate streaming, AgentResponse non-streaming
* Fix mypy/pyright: widen cast types at GroupChat callsites
Eight callsites in _group_chat.py still cast to WorkflowContext[Never,
AgentResponse] but the base orchestrator methods now accept the wider
WorkflowContext[Never, AgentResponse | AgentResponseUpdate] (mode-aware
yields). W_OutT is invariant, so the narrower cast is not assignable.
Magentic was widened in the same commit; this catches the GroupChat
callsites that were missed.
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 40e90c9 commit 339b9c3
19 files changed
Lines changed: 788 additions & 495 deletions
File tree
- python
- packages
- core
- agent_framework/_workflows
- tests/workflow
- orchestrations
- agent_framework_orchestrations
- tests
- samples/03-workflows
- agents
- orchestrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| 531 | + | |
531 | 532 | | |
532 | 533 | | |
533 | 534 | | |
| |||
628 | 629 | | |
629 | 630 | | |
630 | 631 | | |
631 | | - | |
632 | | - | |
633 | 632 | | |
634 | 633 | | |
635 | 634 | | |
636 | 635 | | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
641 | 649 | | |
642 | 650 | | |
643 | 651 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
241 | | - | |
| 243 | + | |
242 | 244 | | |
243 | 245 | | |
244 | | - | |
| 246 | + | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
| |||
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
259 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
264 | 268 | | |
265 | | - | |
| 269 | + | |
266 | 270 | | |
267 | 271 | | |
268 | | - | |
| 272 | + | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| |||
695 | 699 | | |
696 | 700 | | |
697 | 701 | | |
698 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
699 | 705 | | |
700 | 706 | | |
701 | 707 | | |
| |||
704 | 710 | | |
705 | 711 | | |
706 | 712 | | |
707 | | - | |
| 713 | + | |
708 | 714 | | |
709 | 715 | | |
710 | | - | |
| 716 | + | |
711 | 717 | | |
712 | 718 | | |
713 | 719 | | |
| |||
Lines changed: 39 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
355 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
362 | 364 | | |
363 | 365 | | |
364 | 366 | | |
365 | | - | |
366 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
367 | 370 | | |
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
371 | 398 | | |
372 | 399 | | |
373 | 400 | | |
| |||
490 | 517 | | |
491 | 518 | | |
492 | 519 | | |
493 | | - | |
494 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
495 | 524 | | |
496 | 525 | | |
497 | 526 | | |
| |||
501 | 530 | | |
502 | 531 | | |
503 | 532 | | |
504 | | - | |
505 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
506 | 536 | | |
507 | 537 | | |
508 | 538 | | |
| |||
Lines changed: 17 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 110 | | |
115 | 111 | | |
116 | 112 | | |
| |||
127 | 123 | | |
128 | 124 | | |
129 | 125 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 126 | + | |
138 | 127 | | |
139 | 128 | | |
140 | 129 | | |
| |||
190 | 179 | | |
191 | 180 | | |
192 | 181 | | |
193 | | - | |
| 182 | + | |
| 183 | + | |
194 | 184 | | |
195 | 185 | | |
196 | 186 | | |
| |||
222 | 212 | | |
223 | 213 | | |
224 | 214 | | |
225 | | - | |
226 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
227 | 218 | | |
228 | 219 | | |
229 | 220 | | |
| |||
383 | 374 | | |
384 | 375 | | |
385 | 376 | | |
386 | | - | |
| 377 | + | |
387 | 378 | | |
388 | 379 | | |
389 | 380 | | |
| |||
0 commit comments