Files
agent-framework/python/samples/03-workflows/orchestrations/README.md
T
Eduard van Valkenburg a2856d3b92 Python: restructure: Python samples into progressive 01-05 layout (#3862)
* restructure: Python samples into progressive 01-05 layout

- 01-get-started/: 6 numbered steps (hello agent → hosting)
- 02-agents/: all agent concept samples (tools, middleware, providers, etc.)
- 03-workflows/: ALL existing workflow samples preserved as-is
- 04-hosting/: azure-functions, durabletask, a2a
- 05-end-to-end/: demos, evaluation, hosted agents
- Old files moved to _to_delete/ for review
- Added AGENTS.md with structure documentation
- autogen-migration/ and semantic-kernel-migration/ preserved at root

* fix: switch to AzureOpenAI Foundry, fix CI failures

- Switch all 01-get-started samples to AzureOpenAIResponsesClient with
  Azure AI Foundry project endpoint (AZURE_AI_PROJECT_ENDPOINT +
  AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME + AzureCliCredential)
- Add _to_delete/ and 05-end-to-end/ to pyrightconfig.samples.json excludes
- Fix test paths in packages/ that referenced old getting_started/ dirs:
  durabletask conftest + streaming test, azurefunctions conftest,
  devui conftest + capture_messages + openai_sdk_integration
- Fix workflow_as_agent_human_in_the_loop.py import (sibling import)
- Update hosting READMEs and tool comment paths
- Replace root README.md with new structure overview
- Update AGENTS.md to document Azure OpenAI Foundry as default provider

* cleanup: remove _to_delete folder, copy resource files to active dirs

All files in _to_delete/ were either:
- Exact duplicates of files in the new structure (240 files)
- Same file with only comment path updates (100 files)
- One import-fix diff (workflow_as_agent_human_in_the_loop.py)
- One superseded minimal_sample.py

Resource files (sample.pdf, countries.json, employees.pdf, weather.json)
copied to 02-agents/sample_assets/ and 02-agents/resources/ since active
samples reference them.

* fix: address PR review comments, centralize resources, remove root duplicates

- Fix type annotation in 04_memory.py (string union -> proper types)
- Fix old sample paths in observability files
- Fix grammar/spelling in observability samples
- Move sample_assets/ and resources/ to shared/ folder
- Remove 8 duplicate observability files from 02-agents root
- Update resource path references in multimodal_input and provider samples

* fix: update broken links from old getting_started paths to new structure

- Update relative paths in READMEs: getting_started/ → 01-get-started/,
  02-agents/, 03-workflows/, 04-hosting/, 05-end-to-end/
- Fix absolute GitHub URLs in package READMEs
- Fix broken link in ollama package README

* fix: convert absolute GitHub URLs to relative paths for link checker

Absolute URLs to python/samples/ on main branch 404 until PR merges.
Converted to relative paths that linkspector can verify locally.

* fix: update link for handoff sample moved to orchestrations/

* fix: update chatkit-integration README path from demos/ to 05-end-to-end/

* fix: update broken links in orchestrations README to match flat directory structure
2026-02-12 17:36:36 +00:00

10 KiB

Orchestration Getting Started Samples

Installation

The orchestrations package is included when you install agent-framework (which pulls in all optional packages):

pip install agent-framework

Or install the orchestrations package directly:

pip install agent-framework-orchestrations

Orchestration builders are available via the agent_framework.orchestrations submodule:

from agent_framework.orchestrations import (
    SequentialBuilder,
    ConcurrentBuilder,
    HandoffBuilder,
    GroupChatBuilder,
    MagenticBuilder,
)

Samples Overview (by directory)

concurrent

Sample File Concepts
Concurrent Orchestration (Default Aggregator) concurrent_agents.py Fan-out to multiple agents; fan-in with default aggregator returning combined Messages
Concurrent Orchestration (Custom Aggregator) concurrent_custom_aggregator.py Override aggregator via callback; summarize results with an LLM
Concurrent Orchestration (Custom Agent Executors) concurrent_custom_agent_executors.py Child executors own Agents; concurrent fan-out/fan-in via ConcurrentBuilder
Concurrent Orchestration as Agent concurrent_workflow_as_agent.py Build a ConcurrentBuilder workflow and expose it as an agent via workflow.as_agent(...)
Tool Approval with ConcurrentBuilder concurrent_builder_tool_approval.py Require human approval for sensitive tools across concurrent participants
ConcurrentBuilder Request Info concurrent_request_info.py Review concurrent agent outputs before aggregation using .with_request_info()

sequential

Sample File Concepts
Sequential Orchestration (Agents) sequential_agents.py Chain agents sequentially with shared conversation context
Sequential Orchestration (Custom Executor) sequential_custom_executors.py Mix agents with a summarizer that appends a compact summary
Sequential Orchestration as Agent sequential_workflow_as_agent.py Build a SequentialBuilder workflow and expose it as an agent via workflow.as_agent(...)
Tool Approval with SequentialBuilder sequential_builder_tool_approval.py Require human approval for sensitive tools in SequentialBuilder workflows
SequentialBuilder Request Info sequential_request_info.py Request info for agent responses mid-orchestration using .with_request_info()

group-chat

Sample File Concepts
Group Chat with Agent Manager group_chat_agent_manager.py Agent-based manager using with_orchestrator(agent=) to select next speaker
Group Chat Philosophical Debate group_chat_philosophical_debate.py Agent manager moderates long-form, multi-round debate across diverse participants
Group Chat with Simple Selector group_chat_simple_selector.py Group chat with a simple function selector for next speaker
Group Chat Orchestration as Agent group_chat_workflow_as_agent.py Build a GroupChatBuilder workflow and wrap it as an agent for composition
Tool Approval with GroupChatBuilder group_chat_builder_tool_approval.py Require human approval for sensitive tools in group chat orchestration
GroupChatBuilder Request Info group_chat_request_info.py Steer group discussions with periodic guidance using .with_request_info()

handoff

Sample File Concepts
Handoff (Simple) handoff_simple.py Single-tier routing: triage agent routes to specialists, control returns to user after each specialist response
Handoff (Autonomous) handoff_autonomous.py Autonomous mode: specialists iterate independently until invoking a handoff tool using .with_autonomous_mode()
Handoff with Code Interpreter handoff_with_code_interpreter_file.py Retrieve file IDs from code interpreter output in handoff workflow
Handoff with Tool Approval + Checkpoint handoff_with_tool_approval_checkpoint_resume.py Capture tool-approval decisions in checkpoints and resume from persisted state
Handoff Orchestration as Agent handoff_workflow_as_agent.py Build a HandoffBuilder workflow and expose it as an agent, including HITL request/response flow

magentic

Sample File Concepts
Magentic Workflow magentic.py Orchestrate multiple agents with a Magentic manager and streaming
Magentic + Human Plan Review magentic_human_plan_review.py Human reviews or updates the plan before execution
Magentic + Checkpoint Resume magentic_checkpoint.py Resume Magentic orchestration from saved checkpoints
Magentic Orchestration as Agent magentic_workflow_as_agent.py Build a MagenticBuilder workflow and reuse it as an agent

Tips

Magentic checkpointing tip: Treat MagenticBuilder.participants keys as stable identifiers. When resuming from a checkpoint, the rebuilt workflow must reuse the same participant names; otherwise the checkpoint cannot be applied and the run will fail fast.

Handoff workflow tip: Handoff workflows maintain the full conversation history including any Message.additional_properties emitted by your agents. This ensures routing metadata remains intact across all agent transitions. For specialist-to-specialist handoffs, use .add_handoff(source, targets) to configure which agents can route to which others with a fluent, type-safe API.

Sequential orchestration note: Sequential orchestration uses a few small adapter nodes for plumbing:

  • input-conversation normalizes input to list[Message]
  • to-conversation:<participant> converts agent responses into the shared conversation
  • complete publishes the final output event (type='output')

These may appear in event streams (executor_invoked/executor_completed). They're analogous to concurrent's dispatcher and aggregator and can be ignored if you only care about agent activity.

Environment Variables

Orchestration samples that use AzureOpenAIResponsesClient expect:

  • AZURE_AI_PROJECT_ENDPOINT (Azure AI Foundry Agent Service (V2) project endpoint)
  • AZURE_AI_MODEL_DEPLOYMENT_NAME (model deployment name)

These values are passed directly into the client constructor via os.getenv() in sample code.