From 151efd2e803c3584f85015ba096a0bec2ad3cab3 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Oct 2025 19:25:31 -0700 Subject: [PATCH] Python: Remove deprecated add_agent() calls from workflow samples (#1508) * Initial plan * Remove add_agent calls from workflow samples Co-authored-by: moonbox3 <35585003+moonbox3@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: moonbox3 <35585003+moonbox3@users.noreply.github.com> --- .../workflows/agents/azure_ai_agents_streaming.py | 9 ++------- .../agents/azure_chat_agents_function_bridge.py | 4 +--- .../workflows/agents/azure_chat_agents_streaming.py | 10 ++-------- .../azure_chat_agents_tool_calls_with_feedback.py | 2 -- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/python/samples/getting_started/workflows/agents/azure_ai_agents_streaming.py b/python/samples/getting_started/workflows/agents/azure_ai_agents_streaming.py index 3d69241616..12b4cda4c1 100644 --- a/python/samples/getting_started/workflows/agents/azure_ai_agents_streaming.py +++ b/python/samples/getting_started/workflows/agents/azure_ai_agents_streaming.py @@ -16,12 +16,10 @@ A Writer agent generates content, then a Reviewer agent critiques it. The workflow uses streaming so you can observe incremental AgentRunUpdateEvent chunks as each agent produces tokens. Purpose: -Show how to wire chat agents into a WorkflowBuilder pipeline using add_agent -with settings for streaming and workflow outputs. +Show how to wire chat agents into a WorkflowBuilder pipeline by adding agents directly as edges. Demonstrate: - Automatic streaming of agent deltas via AgentRunUpdateEvent when using run_stream(). -- Add an agent via WorkflowBuilder.add_agent() with output_response=True to emit final AgentRunResponse. - Agents adapt to workflow mode: run_stream() emits incremental updates, run() emits complete responses. Prerequisites: @@ -67,13 +65,10 @@ async def main() -> None: "Provide the feedback in the most concise manner possible." ), ) - # Add agents to workflow with custom settings using add_agent. + # Build the workflow by adding agents directly as edges. # Agents adapt to workflow mode: run_stream() for incremental updates, run() for complete responses. - # Reviewer agent emits final AgentRunResponse as a workflow output. workflow = ( WorkflowBuilder() - .add_agent(writer, id="Writer") - .add_agent(reviewer, id="Reviewer", output_response=True) .set_start_executor(writer) .add_edge(writer, reviewer) .build() diff --git a/python/samples/getting_started/workflows/agents/azure_chat_agents_function_bridge.py b/python/samples/getting_started/workflows/agents/azure_chat_agents_function_bridge.py index e760f52c92..a78231444b 100644 --- a/python/samples/getting_started/workflows/agents/azure_chat_agents_function_bridge.py +++ b/python/samples/getting_started/workflows/agents/azure_chat_agents_function_bridge.py @@ -107,11 +107,9 @@ async def main() -> None: workflow = ( WorkflowBuilder() - .add_agent(research_agent, id="research_agent") - .add_agent(final_editor_agent, id="final_editor_agent", output_response=True) + .set_start_executor(research_agent) .add_edge(research_agent, enrich_with_references) .add_edge(enrich_with_references, final_editor_agent) - .set_start_executor(research_agent) .build() ) diff --git a/python/samples/getting_started/workflows/agents/azure_chat_agents_streaming.py b/python/samples/getting_started/workflows/agents/azure_chat_agents_streaming.py index 41fea28536..f811e8460d 100644 --- a/python/samples/getting_started/workflows/agents/azure_chat_agents_streaming.py +++ b/python/samples/getting_started/workflows/agents/azure_chat_agents_streaming.py @@ -13,12 +13,10 @@ A Writer agent generates content, then a Reviewer agent critiques it. The workflow uses streaming so you can observe incremental AgentRunUpdateEvent chunks as each agent produces tokens. Purpose: -Show how to wire chat agents into a WorkflowBuilder pipeline using add_agent -with settings for streaming and workflow outputs. +Show how to wire chat agents into a WorkflowBuilder pipeline by adding agents directly as edges. Demonstrate: - Automatic streaming of agent deltas via AgentRunUpdateEvent when using run_stream(). -- Add an agent via WorkflowBuilder.add_agent() with output_response=True to emit final AgentRunResponse. - Agents adapt to workflow mode: run_stream() emits incremental updates, run() emits complete responses. Prerequisites: @@ -51,14 +49,10 @@ async def main(): ) # Build the workflow using the fluent builder. - # Add agents to workflow with custom settings using add_agent. - # Agents adapt to workflow mode: run_stream() for incremental updates, run() for complete responses. - # Reviewer agent emits final AgentRunResponse as a workflow output. # Set the start node and connect an edge from writer to reviewer. + # Agents adapt to workflow mode: run_stream() for incremental updates, run() for complete responses. workflow = ( WorkflowBuilder() - .add_agent(writer_agent, id="Writer") - .add_agent(reviewer_agent, id="Reviewer", output_response=True) .set_start_executor(writer_agent) .add_edge(writer_agent, reviewer_agent) .build() diff --git a/python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py b/python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py index 919db464e5..aa8efa9cc1 100644 --- a/python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py +++ b/python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py @@ -167,8 +167,6 @@ async def main() -> None: workflow = ( WorkflowBuilder() - .add_agent(writer_agent, id="Writer") - .add_agent(final_editor_agent, id="FinalEditor", output_response=True) .set_start_executor(writer_agent) .add_edge(writer_agent, feedback_coordinator) .add_edge(feedback_coordinator, request_info_executor)