This directory contains samples demonstrating the capabilities of Microsoft Agent Framework for Python.
| File | Description |
|---|---|
getting_started/agents/a2a/agent_with_a2a.py |
Agent2Agent (A2A) Protocol Integration Sample |
| File | Description |
|---|---|
getting_started/agents/anthropic/anthropic_basic.py |
Agent with Anthropic Client |
getting_started/agents/anthropic/anthropic_advanced.py |
Advanced sample with thinking and hosted tools. |
| File | Description |
|---|---|
getting_started/agents/copilotstudio/copilotstudio_basic.py |
Copilot Studio Agent Basic Example |
getting_started/agents/copilotstudio/copilotstudio_with_explicit_settings.py |
Copilot Studio Agent with Explicit Settings Example |
| File | Description |
|---|---|
getting_started/agents/custom/custom_agent.py |
Custom Agent Implementation Example |
getting_started/agents/custom/custom_chat_client.py |
Custom Chat Client Implementation Example |
| File | Description |
|---|---|
getting_started/agents/ollama/ollama_with_openai_chat_client.py |
Ollama with OpenAI Chat Client Example |
| File | Description |
|---|---|
getting_started/chat_client/azure_ai_chat_client.py |
Azure AI Chat Client Direct Usage Example |
getting_started/chat_client/azure_assistants_client.py |
Azure OpenAI Assistants Client Direct Usage Example |
getting_started/chat_client/azure_chat_client.py |
Azure Chat Client Direct Usage Example |
getting_started/chat_client/azure_responses_client.py |
Azure OpenAI Responses Client Direct Usage Example |
getting_started/chat_client/chat_response_cancellation.py |
Chat Response Cancellation Example |
getting_started/chat_client/openai_assistants_client.py |
OpenAI Assistants Client Direct Usage Example |
getting_started/chat_client/openai_chat_client.py |
OpenAI Chat Client Direct Usage Example |
getting_started/chat_client/openai_responses_client.py |
OpenAI Responses Client Direct Usage Example |
| File | Description |
|---|---|
getting_started/context_providers/mem0/mem0_basic.py |
Basic Mem0 integration example |
getting_started/context_providers/mem0/mem0_oss.py |
Mem0 OSS (Open Source) integration example |
getting_started/context_providers/mem0/mem0_threads.py |
Mem0 with thread management example |
| File | Description |
|---|---|
getting_started/context_providers/redis/redis_basics.py |
Basic Redis provider example |
getting_started/context_providers/redis/redis_conversation.py |
Redis conversation context management example |
getting_started/context_providers/redis/redis_threads.py |
Redis with thread management example |
| File | Description |
|---|---|
getting_started/context_providers/simple_context_provider.py |
Simple context provider implementation example |
| File | Description |
|---|---|
getting_started/devui/fanout_workflow/workflow.py |
Complex fan-out/fan-in workflow example |
getting_started/devui/foundry_agent/agent.py |
Azure AI Foundry agent example |
getting_started/devui/in_memory_mode.py |
In-memory mode example for DevUI |
getting_started/devui/spam_workflow/workflow.py |
Spam detection workflow example |
getting_started/devui/weather_agent_azure/agent.py |
Weather agent using Azure OpenAI example |
getting_started/devui/workflow_agents/workflow.py |
Workflow with multiple agents example |
| File | Description |
|---|---|
getting_started/evaluation/azure_ai_foundry/red_team_agent_sample.py |
Red team agent evaluation sample for Azure AI Foundry |
| File | Description |
|---|---|
getting_started/mcp/agent_as_mcp_server.py |
Agent as MCP Server Example |
getting_started/mcp/mcp_api_key_auth.py |
MCP Authentication Example |
| File | Description |
|---|---|
getting_started/multimodal_input/azure_chat_multimodal.py |
Azure OpenAI Chat with multimodal (image) input example |
getting_started/multimodal_input/azure_responses_multimodal.py |
Azure OpenAI Responses with multimodal (image) input example |
getting_started/multimodal_input/openai_chat_multimodal.py |
OpenAI Chat with multimodal (image) input example |
| File | Description |
|---|---|
getting_started/observability/advanced_manual_setup_console_output.py |
Advanced manual observability setup with console output |
getting_started/observability/advanced_zero_code.py |
Zero-code observability setup example |
getting_started/observability/agent_observability.py |
Agent observability example |
getting_started/observability/azure_ai_agent_observability.py |
Azure AI agent observability example |
getting_started/observability/azure_ai_chat_client_with_observability.py |
Azure AI chat client with observability example |
getting_started/observability/setup_observability_with_env_var.py |
Setup observability using environment variables |
getting_started/observability/setup_observability_with_parameters.py |
Setup observability using parameters |
getting_started/observability/workflow_observability.py |
Workflow observability example |
| File | Description |
|---|---|
getting_started/threads/custom_chat_message_store_thread.py |
Implementation of custom chat message store state |
getting_started/threads/redis_chat_message_store_thread.py |
Basic example of using Redis chat message store |
getting_started/threads/suspend_resume_thread.py |
Demonstrates how to suspend and resume a service-managed thread |
| File | Description |
|---|---|
getting_started/tools/ai_function_declaration_only.py |
Function declarations without implementations for testing agent reasoning |
getting_started/tools/ai_function_from_dict_with_dependency_injection.py |
Creating AI functions from dictionary definitions using dependency injection |
getting_started/tools/ai_function_recover_from_failures.py |
Graceful error handling when tools raise exceptions |
getting_started/tools/ai_function_with_approval.py |
User approval workflows for function calls without threads |
getting_started/tools/ai_function_with_approval_and_threads.py |
Tool approval workflows using threads for conversation history management |
getting_started/tools/ai_function_with_max_exceptions.py |
Limiting tool failure exceptions using max_invocation_exceptions |
getting_started/tools/ai_function_with_max_invocations.py |
Limiting total tool invocations using max_invocations |
getting_started/tools/ai_functions_in_class.py |
Using ai_function decorator with class methods for stateful tools |
| File | Description |
|---|---|
getting_started/workflows/_start-here/step1_executors_and_edges.py |
Step 1: Foundational patterns: Executors and edges |
getting_started/workflows/_start-here/step2_agents_in_a_workflow.py |
Step 2: Agents in a Workflow non-streaming |
getting_started/workflows/_start-here/step3_streaming.py |
Step 3: Agents in a workflow with streaming |
| File | Description |
|---|---|
getting_started/workflows/agents/azure_ai_agents_streaming.py |
Sample: Agents in a workflow with streaming |
getting_started/workflows/agents/azure_chat_agents_function_bridge.py |
Sample: Two agents connected by a function executor bridge |
getting_started/workflows/agents/azure_chat_agents_streaming.py |
Sample: Agents in a workflow with streaming |
getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py |
Sample: Tool-enabled agents with human feedback |
getting_started/workflows/agents/custom_agent_executors.py |
Step 2: Agents in a Workflow non-streaming |
getting_started/workflows/agents/workflow_as_agent_human_in_the_loop.py |
Sample: Workflow Agent with Human-in-the-Loop |
getting_started/workflows/agents/workflow_as_agent_reflection_pattern.py |
Sample: Workflow as Agent with Reflection and Retry Pattern |
| File | Description |
|---|---|
getting_started/workflows/checkpoint/checkpoint_with_human_in_the_loop.py |
Sample: Checkpoint + human-in-the-loop quickstart |
getting_started/workflows/checkpoint/checkpoint_with_resume.py |
Sample: Checkpointing and Resuming a Workflow (with an Agent stage) |
getting_started/workflows/checkpoint/sub_workflow_checkpoint.py |
Sample: Checkpointing for workflows that embed sub-workflows |
| File | Description |
|---|---|
getting_started/workflows/composition/sub_workflow_basics.py |
Sample: Sub-Workflows (Basics) |
getting_started/workflows/composition/sub_workflow_parallel_requests.py |
Sample: Sub-workflow with parallel request handling by specialized interceptors |
getting_started/workflows/composition/sub_workflow_request_interception.py |
Sample: Sub-Workflows with Request Interception |
| File | Description |
|---|---|
getting_started/workflows/control-flow/edge_condition.py |
Sample: Conditional routing with structured outputs |
getting_started/workflows/control-flow/multi_selection_edge_group.py |
Step 06b — Multi-Selection Edge Group sample |
getting_started/workflows/control-flow/sequential_executors.py |
Sample: Sequential workflow with streaming |
getting_started/workflows/control-flow/sequential_streaming.py |
Sample: Foundational sequential workflow with streaming using function-style executors |
getting_started/workflows/control-flow/simple_loop.py |
Sample: Simple Loop (with an Agent Judge) |
getting_started/workflows/control-flow/switch_case_edge_group.py |
Sample: Switch-Case Edge Group with an explicit Uncertain branch |
| File | Description |
|---|---|
getting_started/workflows/human-in-the-loop/guessing_game_with_human_input.py |
Sample: Human in the loop guessing game |
getting_started/workflows/human-in-the-loop/agents_with_approval_requests.py |
Sample: Agents with Approval Requests in Workflows |
| File | Description |
|---|---|
getting_started/workflows/observability/tracing_basics.py |
Basic tracing workflow sample |
| File | Description |
|---|---|
getting_started/workflows/orchestration/concurrent_agents.py |
Sample: Concurrent fan-out/fan-in (agent-only API) with default aggregator |
getting_started/workflows/orchestration/concurrent_custom_agent_executors.py |
Sample: Concurrent Orchestration with Custom Agent Executors |
getting_started/workflows/orchestration/concurrent_custom_aggregator.py |
Sample: Concurrent Orchestration with Custom Aggregator |
getting_started/workflows/orchestration/group_chat_prompt_based_manager.py |
Sample: Group Chat Orchestration with LLM-based manager |
getting_started/workflows/orchestration/group_chat_simple_selector.py |
Sample: Group Chat Orchestration with function-based speaker selector |
getting_started/workflows/orchestration/handoff_simple.py |
Sample: Handoff Orchestration with simple agent handoff pattern |
getting_started/workflows/orchestration/handoff_specialist_to_specialist.py |
Sample: Handoff Orchestration with specialist-to-specialist routing |
getting_started/workflows/orchestration/handoff_return_to_previous |
Return-to-previous routing: after user input, routes back to the previous specialist instead of coordinator using .enable_return_to_previous() |
getting_started/workflows/orchestration/magentic.py |
Sample: Magentic Orchestration (agentic task planning with multi-agent execution) |
getting_started/workflows/orchestration/magentic_checkpoint.py |
Sample: Magentic Orchestration with Checkpointing |
getting_started/workflows/orchestration/magentic_human_plan_update.py |
Sample: Magentic Orchestration with Human Plan Review |
getting_started/workflows/orchestration/sequential_agents.py |
Sample: Sequential workflow (agent-focused API) with shared conversation context |
getting_started/workflows/orchestration/sequential_custom_executors.py |
Sample: Sequential workflow mixing agents and a custom summarizer executor |
| File | Description |
|---|---|
getting_started/workflows/parallelism/aggregate_results_of_different_types.py |
Sample: Concurrent fan out and fan in with two different tasks that output results of different types |
getting_started/workflows/parallelism/fan_out_fan_in_edges.py |
Sample: Concurrent fan out and fan in with three domain agents |
getting_started/workflows/parallelism/map_reduce_and_visualization.py |
Sample: Map reduce word count with fan out and fan in over file backed intermediate results |
| File | Description |
|---|---|
getting_started/workflows/state-management/shared_states_with_agents.py |
Sample: Shared state with agents and conditional routing |
| File | Description |
|---|---|
getting_started/workflows/visualization/concurrent_with_visualization.py |
Sample: Concurrent (Fan-out/Fan-in) with Agents + Visualization |
For information on creating new samples, see SAMPLE_GUIDELINES.md.