Lesson 2 of 4 Multi-Agent Orchestration Patterns and Frameworks

Orchestrating Agents with Microsoft Agent Framework

This lesson describes the agents, workflows and built-in orchestrations of Microsoft Agent Framework, Microsoft's open-source framework for agents and multi-agent workflows in Python and .NET and the successor to Semantic Kernel agents and AutoGen.

Learning outcomes

After completing this lesson, you will be able to:

  • Create an agent with a chat client, instructions and tools.
  • Build workflows of executors connected by typed edges.
  • Use the built-in orchestration builders.
  • Combine deterministic rules and agents in one workflow.

Agents and tools

An Agent combines a chat client, instructions, tools and optional middleware and context providers. The agent-framework-foundry package provides FoundryChatClient, which connects to a Foundry project endpoint with a Microsoft Entra ID credential. Python functions become tools with the @tool decorator, which can also mark a tool as requiring approval.

from agent_framework import Agent, tool
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential

client = FoundryChatClient(project_endpoint=PROJECT_ENDPOINT, model="gpt-5-mini", credential=AzureCliCredential())

@tool(approval_mode="always_require")
def issue_refund(order_id: str, amount: float) -> str:
    '''Issue a refund for an order. Requires human approval.'''
    return payments.refund(order_id, amount, idempotency_key=f"refund-{order_id}")

refunds = Agent(client=client, name="refunds", instructions="You handle refund requests.", tools=[issue_refund])
True or false

Agent Framework agents

Exam skills 2.4.6

Check the building blocks of an Agent Framework agent.

Log in to try this activity Interactive activities are free with an account.

Workflows

Workflows are graphs of executors (agents or plain functions) connected by edges that carry typed messages. Edges can be conditional, fan out to several executors and fan in to an aggregator. Workflows support checkpointing, so a run can pause and resume later, and human-in-the-loop requests, which emit a request_info event and wait for a response. Workflows can also be declared in YAML. Because deterministic executors sit beside agents, a workflow can keep business rules in code and call agents only for judgement.

The following diagram shows a workflow graph with function and agent executors.

A Microsoft Agent Framework workflow. Executors, which are agents or plain functions, are connected by edges that carry typed messages. Edges can be conditional, fan out to several executors and fan in to an aggregator. A workflow can checkpoint so a run pauses and resumes, and it can request human input, emitting a request_info event and waiting for the response. Deterministic executors keep business rules in code, calling agents only for judgement.
Rules stay in code; agents handle judgement.
Match the pairs

Workflow building blocks

Exam skills 2.4.6

Match each Agent Framework workflow feature with what it provides.

Log in to try this activity Interactive activities are free with an account.

Built-in orchestrations

The agent-framework-orchestrations package provides ready-made builders for common patterns: SequentialBuilder, ConcurrentBuilder, HandoffBuilder, GroupChatBuilder and MagenticBuilder. Each builds a workflow from a list of participants.

from agent_framework.orchestrations import SequentialBuilder, ConcurrentBuilder

writer = client.as_agent(name="writer", instructions="Draft a short product announcement.")
reviewer = client.as_agent(name="reviewer", instructions="Check the previous draft for unsupported claims and fix them.")
pipeline = SequentialBuilder(participants=[writer, reviewer], chain_only_agent_responses=True).build()

events = await pipeline.run("Announce the new 2-year warranty on all blenders.")
print(events.get_outputs()[0].text)

panel = ConcurrentBuilder(participants=[market_agent, legal_agent, tech_agent]).build()   # fan-out and aggregate

By default, each agent in a sequential orchestration receives the previous agent's full conversation; chain_only_agent_responses=True passes only the previous response, which saves tokens. Tools marked as requiring approval pause the orchestration with a request that the application answers before resuming.

Scenario questions

Choosing a builder

Exam skills 2.4.6

Choose the Agent Framework orchestration builder for each need.

Log in to try this activity Interactive activities are free with an account.
Worked example

Mixing rules and agents

A bank's onboarding process must verify documents with a fixed rules engine, then have an agent summarize risk, then route high-risk cases to a compliance officer for approval before account creation. The process can wait days for approval.

An Agent Framework workflow fits: a function executor calls the rules engine, an agent executor summarizes risk, a conditional edge routes high-risk cases to a human-in-the-loop request, and checkpointing persists the state while waiting. A single agent with all steps in its instructions would not guarantee the rules check or survive a multi-day wait.

Check yourself

How does Microsoft Agent Framework pause a tool call for human approval?

Show answer

The tool is declared with approval_mode="always_require", and the workflow waits for the approval before running it.

Exam Tips

Remember for the exam

  • Agent Framework: agents, typed workflows, checkpointing, human-in-the-loop, built-in orchestrations.
  • @tool(approval_mode="always_require") pauses for approval.
  • Keep deterministic rules in function executors beside agents.