A comprehensive collection of learning resources for building AI-powered systems using the Microsoft Agent Framework. This repository includes both an interactive Jupyter notebook tutorial and standalone Python examples demonstrating advanced orchestration patterns.
This repository contains two main learning resources:
An interactive tutorial that progressively teaches framework capabilities:
- ✅ Classifies incoming emails (Spam / Not Spam / Uncertain)
- ✅ Looks up customer SLA and ticket status via function tools
- ✅ Drafts professional responses with customizable tone
- ✅ Requires approval before sending sensitive replies
- ✅ Remembers user preferences (language, tone, name)
- ✅ Processes in parallel for long emails (response + summary)
- ✅ Uses multiple reviewers for quality control (security, tone, accuracy)
- ✅ Logs every operation for observability
A Magentic orchestration demo featuring collaborative AI agents:
- 🔍 Market Researcher - Pessimistic analyst focused on risks
- 💰 Financial Analyst - Optimistic view on revenue potential
- ⚙️ Tech Advisor - Skeptical technical feasibility assessor
- 🎯 Magentic Manager - Coordinates the team and balances perspectives
- 📄 Live Logging - Real-time Markdown discussion logs
- ⚡ Streaming Output - See agent discussions as they happen
- 🔄 Human-in-the-Loop - Optional plan review and approval
- ✅ Azure subscription with access to Azure OpenAI
- ✅ Azure OpenAI resource with a deployed model (e.g.,
gpt-4o-mini) - ✅ Azure CLI installed and authenticated (
az login) - ✅ Python 3.10+
- ✅ Azure AI Foundry project (Section 7 — MCP Integration only)
- Project endpoint — found in your project's Overview page
- Model deployment name — found in your project's Models + endpoints page
# 1. Clone the repository
git clone https://github.com/moti-malka/agent-framework.git
cd agent-framework
# 2. Create virtual environment
python3.10 -m venv .venv
source .venv/bin/activate # macOS/Linux
# or .venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment
# Create a .env file with your Azure OpenAI configuration:
AZURE_OPENAI_ENDPOINT=https://your-apim-gateway.azure-api.net # APIM gateway URL
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o-mini
AZURE_OPENAI_API_KEY=your-apim-subscription-key # APIM subscription key
API_VERSION=2025-01-01-preview # Optional, defaults to this value
# 5. Login to Azure (for CLI-based authentication)
az loginOption 1: Jupyter Notebook Tutorial
# Open the notebook
jupyter notebook agent_framework.ipynb
# Or open in VS Code with Jupyter extensionOption 2: Standalone Magentic Demo
# Run the startup analyzer
python magentic_example.py
# Follow the interactive prompts to:
# - Choose streaming or human-in-the-loop mode
# - Select a pre-defined startup idea or enter your own
# - Watch agents collaborate in real-time
# - Review the generated discussion log in discussions/ folder| Feature | Section | Description |
|---|---|---|
| ChatAgent | 1-3 | Core agent with instructions, streaming, threads |
| Function Tools | 4 | @tool decorator for custom capabilities |
| Approval Mode | 5 | approval_mode="always_require" for HITL |
| Middleware | 6 | Agent and function invocation hooks |
| ContextProvider | 7 | Memory with invoking/invoked lifecycle |
| WorkflowBuilder | 8-10 | Sequential, branching, fan-out patterns |
| AgentExecutor | 8-10 | Wrap agents for workflow orchestration |
| Switch-Case | 9 | Multi-way routing with Case/Default |
| Multi-Selection | 10 | Dynamic fan-out to parallel paths |
| Fan-In | 10 | Aggregate results from parallel execution |
| ConcurrentBuilder | 11 | Parallel multi-agent processing |
| MagenticBuilder | 11 | Manager-orchestrated agent teams |
| Feature | Description |
|---|---|
| MagenticBuilder | Dynamic team coordination with manager agent |
| Specialized Agents | Role-based agents with distinct personalities |
| Streaming Events | Real-time agent updates via AgentRunUpdateEvent |
| Progress Tracking | MagenticProgressLedger for workflow state |
| Plan Review | Human-in-the-loop approval with MagenticPlanReviewRequest |
| Discussion Logging | Custom middleware for Markdown conversation logs |
| Agent Middleware | Custom logging hooks for observability |
| Azure Authentication | Both API key and Azure CLI auth support |
agent-framework/
├── agent_framework.ipynb # Interactive tutorial notebook (12 sections)
├── magentic_example.py # Standalone Magentic orchestration demo
├── requirements.txt # Python dependencies
├── .env # Azure OpenAI configuration (create this)
├── .venv/ # Python virtual environment
├── images/ # Architecture and workflow diagrams
│ ├── agent-components.png
│ ├── concurrent-workflow.png
│ ├── group-chat.png
│ ├── magentic-workflow.png
│ ├── sequential-workflow.png
│ ├── threads-and-memory.png
│ └── workflow-example.png
├── discussions/ # Created by magentic_example.py at runtime (Markdown logs)
└── README.md # This file
Create a .env file in the project root with the following variables:
# Required: Azure OpenAI Configuration (Sections 1–16)
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o-mini
# Optional: API Key (if not using Azure CLI authentication)
AZURE_OPENAI_API_KEY=your-api-key
# Optional: API Version (defaults to 2025-01-01-preview)
API_VERSION=2025-01-01-preview
# Required for Section 7 only (MCP Integration)
# AZURE_AI_PROJECT_ENDPOINT: Azure AI Foundry → your project → Overview → Project endpoint
AZURE_AI_PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>
# AZURE_AI_MODEL_DEPLOYMENT_NAME: Azure AI Foundry → your project → Models + endpoints → Deployment name
AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4o-miniAuthentication Options:
- Azure CLI (recommended): Run
az loginbefore starting - API Key: Set
AZURE_OPENAI_API_KEYin.env
The agent_framework.ipynb tutorial is organized into 12 progressive sections:
| # | Section | What You'll Learn |
|---|---|---|
| 0 | Shared Setup | Environment, models, sample data |
| 1 | Basic Agent | Create and run your first agent |
| 2 | Streaming | Real-time token streaming |
| 3 | Multi-Turn Conversations | Thread-based memory |
| 4 | Function Tools | Add custom capabilities |
| 5 | Human-in-the-Loop | Approval workflows |
| 6 | Middleware | Logging & observability |
| 7 | Memory | Persistent user context |
| 8 | Sequential Workflows | Classify → Draft → Review |
| 9 | Branching Logic | Spam vs. NotSpam vs. Uncertain |
| 10 | Fan-Out/Fan-In | Parallel processing |
| 11 | Multi-Agent Group Chat | Team collaboration |
| 12 | Capstone Demo | End-to-end system |
MIT