Python: Update fan in fan out sample to show concurrency (#2705)

* Update fan in fan out sample to show concurrency

* Update python/samples/getting_started/workflows/parallelism/fan_out_fan_in_edges.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Tao Chen
2025-12-08 11:53:37 -08:00
committed by GitHub
Unverified
parent 0675000f4b
commit d7ca96923b
@@ -6,10 +6,11 @@ from dataclasses import dataclass
from agent_framework import ( # Core chat primitives to build LLM requests
AgentExecutorRequest, # The message bundle sent to an AgentExecutor
AgentExecutorResponse, # The structured result returned by an AgentExecutor
AgentRunEvent,
ChatAgent, # Tracing event for agent execution steps
ChatMessage, # Chat message structure
Executor, # Base class for custom Python executors
ExecutorCompletedEvent,
ExecutorInvokedEvent,
Role, # Enum of chat roles (user, assistant, system)
WorkflowBuilder, # Fluent builder for wiring the workflow graph
WorkflowContext, # Per run context and event bus
@@ -141,9 +142,11 @@ async def main() -> None:
# 3) Run with a single prompt and print progress plus the final consolidated output
async for event in workflow.run_stream("We are launching a new budget-friendly electric bike for urban commuters."):
if isinstance(event, AgentRunEvent):
# Show which agent ran and what step completed for lightweight observability.
print(event)
if isinstance(event, ExecutorInvokedEvent):
# Show when executors are invoked and completed for lightweight observability.
print(f"{event.executor_id} invoked")
elif isinstance(event, ExecutorCompletedEvent):
print(f"{event.executor_id} completed")
elif isinstance(event, WorkflowOutputEvent):
print("===== Final Aggregated Output =====")
print(event.data)