mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
9148392d00
* improvements in dep injection and sample * fix for falsy default * fix mypy * update to use a nested dict instead of a string. * clarify docs * Update python/packages/core/agent_framework/_tools.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/packages/core/agent_framework/_tools.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/packages/core/agent_framework/_tools.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/packages/core/agent_framework/_serialization.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * format --------- Co-authored-by: eavanvalkenburg <github@vanvalkenburg.eu> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
9148392d00
·
2025-10-13 20:34:27 +00:00
History
Python Samples
This directory contains samples demonstrating the capabilities of Microsoft Agent Framework for Python.
Agents
A2A (Agent-to-Agent)
| File | Description |
|---|---|
getting_started/agents/a2a/agent_with_a2a.py |
Agent2Agent (A2A) Protocol Integration Sample |
Anthropic
| File | Description |
|---|---|
getting_started/agents/anthropic/anthropic_with_openai_chat_client.py |
Anthropic with OpenAI Chat Client Example |
Azure AI
Azure OpenAI
Copilot Studio
| 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 |
Custom
| 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 |
Ollama
| File | Description |
|---|---|
getting_started/agents/ollama/ollama_with_openai_chat_client.py |
Ollama with OpenAI Chat Client Example |
OpenAI
Chat Client
| 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 |
Context Providers
Mem0
| 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 |
Redis
| 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 |
Other
| File | Description |
|---|---|
getting_started/context_providers/simple_context_provider.py |
Simple context provider implementation example |
DevUI
| 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 |
Evaluation
| File | Description |
|---|---|
getting_started/evaluation/azure_ai_foundry/red_team_agent_sample.py |
Red team agent evaluation sample for Azure AI Foundry |
MCP (Model Context Protocol)
| 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 |
Middleware
| File | Description |
|---|---|
getting_started/middleware/agent_and_run_level_middleware.py |
Agent and run-level middleware example |
getting_started/middleware/chat_middleware.py |
Chat middleware example |
getting_started/middleware/class_based_middleware.py |
Class-based middleware implementation example |
getting_started/middleware/decorator_middleware.py |
Decorator-based middleware example |
getting_started/middleware/exception_handling_with_middleware.py |
Exception handling with middleware example |
getting_started/middleware/function_based_middleware.py |
Function-based middleware example |
getting_started/middleware/middleware_termination.py |
Middleware termination example |
getting_started/middleware/override_result_with_middleware.py |
Override result with middleware example |
getting_started/middleware/shared_state_middleware.py |
Shared state middleware example |
Multimodal Input
| 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 |
Observability
| 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 |
Threads
| 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 |
Tools
| File | Description |
|---|---|
getting_started/tools/ai_tool_with_approval.py |
Demonstration of a tool with approvals |
getting_started/tools/ai_tool_with_approval_and_threads.py |
Tool Approvals with Threads |
getting_started/tools/failing_tools.py |
Tool exceptions handled by returning the error for the agent to recover from |
Workflows
Start Here
| 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 |
Agents in Workflows
| 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 |
Checkpoint
| 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 |
Composition
| 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 |
Control Flow
| 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 |
Human-in-the-Loop
| File | Description |
|---|---|
getting_started/workflows/human-in-the-loop/guessing_game_with_human_input.py |
Sample: Human in the loop guessing game |
Observability
| File | Description |
|---|---|
getting_started/workflows/observability/tracing_basics.py |
Basic tracing workflow sample |
Orchestration
Parallelism
| 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 |
State Management
| File | Description |
|---|---|
getting_started/workflows/state-management/shared_states_with_agents.py |
Sample: Shared state with agents and conditional routing |
Visualization
| File | Description |
|---|---|
getting_started/workflows/visualization/concurrent_with_visualization.py |
Sample: Concurrent (Fan-out/Fan-in) with Agents + Visualization |
Sample Guidelines
For information on creating new samples, see SAMPLE_GUIDELINES.md.