Skip to content

Latest commit

History

History

README.md

Workflows Getting Started Samples

Installation

Microsoft Agent Framework Workflows support ships with the core agent-framework or agent-framework-core package, so no extra installation step is required.

To install with visualization support:

pip install agent-framework[viz] --pre

To export visualization images you also need to install GraphViz.

Samples Overview

Foundational Concepts - Start Here

Begin with the _start-here folder in order. These three samples introduce the core ideas of executors, edges, agents in workflows, and streaming.

SampleFileConcepts
Executors and Edges_start-here/step1_executors_and_edges.pyMinimal workflow with basic executors and edges
Agents in a Workflow_start-here/step2_agents_in_a_workflow.pyIntroduces adding Agents as nodes; calling agents inside a workflow
Streaming (Basics)_start-here/step3_streaming.pyExtends workflows with event streaming

Once comfortable with these, explore the rest of the samples below.


Samples Overview (by directory)

agents

SampleFileConcepts
Azure Chat Agents (Streaming)agents/azure_chat_agents_streaming.pyAdd Azure agents as edges and handle streaming events
Custom Agent Executorsagents/custom_agent_executors.pyCreate executors to handle agent run methods
Azure AI Chat Agents (Streaming)agents/azure_ai_agents_streaming.pyAdd Azure AI agents as edges and handle streaming events
Azure Chat Agents (Streaming)agents/azure_chat_agents_streaming.pyAdd Azure Chat agents as edges and handle streaming events
Workflow as Agent (Reflection Pattern)agents/workflow_as_agent_reflection_pattern.pyWrap a workflow so it can behave like an agent (reflection pattern)
Workflow as Agent + HITLagents/workflow_as_agent_human_in_the_loop.pyExtend workflow-as-agent with human-in-the-loop capability

checkpoint

SampleFileConcepts
Checkpoint & Resumecheckpoint/checkpoint_with_resume.pyCreate checkpoints, inspect them, and resume execution
Checkpoint & HITL Resumecheckpoint/checkpoint_with_human_in_the_loop.pyCombine checkpointing with human approvals and resume pending HITL requests
Checkpointed Sub-Workflowcheckpoint/sub_workflow_checkpoint.pySave and resume a sub-workflow that pauses for human approval

composition

SampleFileConcepts
Sub-Workflow (Basics)composition/sub_workflow_basics.pyWrap a workflow as an executor and orchestrate sub-workflows
Sub-Workflow: Request Interceptioncomposition/sub_workflow_request_interception.pyIntercept and forward sub-workflow requests using @handler for RequestInfoMessage subclasses
Sub-Workflow: Parallel Requestscomposition/sub_workflow_parallel_requests.pyMultiple specialized interceptors handling different request types from same sub-workflow

control-flow

SampleFileConcepts
Sequential Executorscontrol-flow/sequential_executors.pySequential workflow with explicit executor setup
Sequential (Streaming)control-flow/sequential_streaming.pyStream events from a simple sequential run
Edge Conditioncontrol-flow/edge_condition.pyConditional routing based on agent classification
Switch-Case Edge Groupcontrol-flow/switch_case_edge_group.pySwitch-case branching using classifier outputs
Multi-Selection Edge Groupcontrol-flow/multi_selection_edge_group.pySelect one or many targets dynamically (subset fan-out)
Simple Loopcontrol-flow/simple_loop.pyFeedback loop where an agent judges ABOVE/BELOW/MATCHED

human-in-the-loop

SampleFileConcepts
Human-In-The-Loop (Guessing Game)human-in-the-loop/guessing_game_with_human_input.pyInteractive request/response prompts with a human

observability

SampleFileConcepts
Tracing (Basics)observability/tracing_basics.pyUse basic tracing for workflow telemetry. Refer to this directory to learn more about observability concepts.

orchestration

SampleFileConcepts
Concurrent Orchestration (Default Aggregator)orchestration/concurrent_agents.pyFan-out to multiple agents; fan-in with default aggregator returning combined ChatMessages
Concurrent Orchestration (Custom Aggregator)orchestration/concurrent_custom_aggregator.pyOverride aggregator via callback; summarize results with an LLM
Concurrent Orchestration (Custom Agent Executors)orchestration/concurrent_custom_agent_executors.pyChild executors own ChatAgents; concurrent fan-out/fan-in via ConcurrentBuilder
Magentic Workflow (Multi-Agent)orchestration/magentic.pyOrchestrate multiple agents with Magentic manager and streaming
Magentic + Human Plan Revieworchestration/magentic_human_plan_update.pyHuman reviews/updates the plan before execution
Magentic + Checkpoint Resumeorchestration/magentic_checkpoint.pyResume Magentic orchestration from saved checkpoints
Sequential Orchestration (Agents)orchestration/sequential_agents.pyChain agents sequentially with shared conversation context
Sequential Orchestration (Custom Executor)orchestration/sequential_custom_executors.pyMix agents with a summarizer that appends a compact summary

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.

parallelism

SampleFileConcepts
Concurrent (Fan-out/Fan-in)parallelism/fan_out_fan_in_edges.pyDispatch to multiple executors and aggregate results
Aggregate Results of Different Typesparallelism/aggregate_results_of_different_types.pyHandle results of different types from multiple concurrent executors
Map-Reduce with Visualizationparallelism/map_reduce_and_visualization.pyFan-out/fan-in pattern with diagram export

state-management

SampleFileConcepts
Shared Statesstate-management/shared_states_with_agents.pyStore in shared state once and later reuse across agents

visualization

SampleFileConcepts
Concurrent with Visualizationvisualization/concurrent_with_visualization.pyFan-out/fan-in workflow with diagram export

resources

Notes

  • Agent-based samples use provider SDKs (Azure/OpenAI, etc.). Ensure credentials are configured, or adapt agents accordingly.

Sequential orchestration uses a few small adapter nodes for plumbing:

  • "input-conversation" normalizes input to list[ChatMessage]
  • "to-conversation:" converts agent responses into the shared conversation
  • "complete" publishes the final WorkflowOutputEvent These may appear in event streams (ExecutorInvoke/Completed). They’re analogous to concurrent’s dispatcher and aggregator and can be ignored if you only care about agent activity.

Environment Variables