|
| 1 | +# 🔄 Basic Agent Workflows with GitHub Models (.NET) |
| 2 | + |
| 3 | +## 📋 Workflow Orchestration Tutorial |
| 4 | + |
| 5 | +This notebook demonstrates how to build sophisticated **agent workflows** using the Microsoft Agent Framework for .NET and GitHub Models. You'll learn to create multi-step business processes where AI agents collaborate to accomplish complex tasks through structured orchestration patterns. |
| 6 | + |
| 7 | +## 🎯 Learning Objectives |
| 8 | + |
| 9 | +### 🏗️ **Workflow Architecture Fundamentals** |
| 10 | +- **Workflow Builder**: Design and orchestrate complex multi-step AI processes |
| 11 | +- **Agent Coordination**: Coordinate multiple specialized agents within workflows |
| 12 | +- **GitHub Models Integration**: Leverage GitHub's AI model inference service in workflows |
| 13 | +- **Visual Workflow Design**: Create and visualize workflow structures for better understanding |
| 14 | + |
| 15 | +### 🔄 **Process Orchestration Patterns** |
| 16 | +- **Sequential Processing**: Chain multiple agent tasks in logical order |
| 17 | +- **State Management**: Maintain context and data flow across workflow stages |
| 18 | +- **Error Handling**: Implement robust error recovery and workflow resilience |
| 19 | +- **Performance Optimization**: Design efficient workflows for enterprise-scale operations |
| 20 | + |
| 21 | +### 🏢 **Enterprise Workflow Applications** |
| 22 | +- **Business Process Automation**: Automate complex organizational workflows |
| 23 | +- **Content Production Pipeline**: Editorial workflows with review and approval stages |
| 24 | +- **Customer Service Automation**: Multi-step customer inquiry resolution |
| 25 | +- **Data Processing Workflows**: ETL workflows with AI-powered transformation |
| 26 | + |
| 27 | +## ⚙️ Prerequisites & Setup |
| 28 | + |
| 29 | +### 📦 **Required NuGet Packages** |
| 30 | + |
| 31 | +This workflow demonstration uses several key .NET packages: |
| 32 | + |
| 33 | +```xml |
| 34 | +<!-- Core AI Framework --> |
| 35 | +<PackageReference Include="Microsoft.Extensions.AI" Version="9.9.0" /> |
| 36 | + |
| 37 | +<!-- Agent Framework (Local Development) --> |
| 38 | +<!-- Microsoft.Agents.AI.dll - Core agent abstractions --> |
| 39 | +<!-- Microsoft.Agents.AI.OpenAI.dll - OpenAI/GitHub Models integration --> |
| 40 | + |
| 41 | +<!-- Configuration and Environment --> |
| 42 | +<PackageReference Include="DotNetEnv" Version="3.1.1" /> |
| 43 | +``` |
| 44 | + |
| 45 | +### 🔑 **GitHub Models Configuration** |
| 46 | + |
| 47 | +**Environment Setup (.env file):** |
| 48 | +```env |
| 49 | +GITHUB_TOKEN=your_github_personal_access_token |
| 50 | +GITHUB_ENDPOINT=https://models.inference.ai.azure.com |
| 51 | +GITHUB_MODEL_ID=gpt-4o-mini |
| 52 | +``` |
| 53 | + |
| 54 | +**GitHub Models Access:** |
| 55 | +1. Sign up for GitHub Models (currently in preview) |
| 56 | +2. Generate a personal access token with model access permissions |
| 57 | +3. Configure environment variables as shown above |
| 58 | + |
| 59 | +### 🏗️ **Workflow Architecture Overview** |
| 60 | + |
| 61 | +```mermaid |
| 62 | +graph TD |
| 63 | + A[Workflow Builder] --> B[Agent Registry] |
| 64 | + B --> C[Workflow Execution Engine] |
| 65 | + C --> D[Agent 1: Content Generator] |
| 66 | + C --> E[Agent 2: Content Reviewer] |
| 67 | + D --> F[Workflow Results] |
| 68 | + E --> F |
| 69 | + G[GitHub Models API] --> D |
| 70 | + G --> E |
| 71 | +``` |
| 72 | + |
| 73 | +**Key Components:** |
| 74 | +- **WorkflowBuilder**: Main orchestration engine for designing workflows |
| 75 | +- **AIAgent**: Individual specialized agents with specific capabilities |
| 76 | +- **GitHub Models Client**: AI model inference service integration |
| 77 | +- **Execution Context**: Manages state and data flow between workflow stages |
| 78 | + |
| 79 | +## 🎨 **Enterprise Workflow Design Patterns** |
| 80 | + |
| 81 | +### 📝 **Content Production Workflow** |
| 82 | +``` |
| 83 | +User Request → Content Generation → Quality Review → Final Output |
| 84 | +``` |
| 85 | + |
| 86 | +### 🔍 **Document Processing Pipeline** |
| 87 | +``` |
| 88 | +Document Input → Analysis → Extraction → Validation → Structured Output |
| 89 | +``` |
| 90 | + |
| 91 | +### 💼 **Business Intelligence Workflow** |
| 92 | +``` |
| 93 | +Data Collection → Processing → Analysis → Report Generation → Distribution |
| 94 | +``` |
| 95 | + |
| 96 | +### 🤝 **Customer Service Automation** |
| 97 | +``` |
| 98 | +Customer Inquiry → Classification → Processing → Response Generation → Follow-up |
| 99 | +``` |
| 100 | + |
| 101 | +## 🏢 **Enterprise Benefits** |
| 102 | + |
| 103 | +### 🎯 **Reliability & Scalability** |
| 104 | +- **Deterministic Execution**: Consistent, repeatable workflow outcomes |
| 105 | +- **Error Recovery**: Graceful handling of failures at any workflow stage |
| 106 | +- **Performance Monitoring**: Track execution metrics and optimization opportunities |
| 107 | +- **Resource Management**: Efficient allocation and utilization of AI model resources |
| 108 | + |
| 109 | +### 🔒 **Security & Compliance** |
| 110 | +- **Secure Authentication**: GitHub token-based authentication for API access |
| 111 | +- **Audit Trails**: Complete logging of workflow execution and decision points |
| 112 | +- **Access Control**: Granular permissions for workflow execution and monitoring |
| 113 | +- **Data Privacy**: Secure handling of sensitive information throughout workflows |
| 114 | + |
| 115 | +### 📊 **Observability & Management** |
| 116 | +- **Visual Workflow Design**: Clear representation of process flows and dependencies |
| 117 | +- **Execution Monitoring**: Real-time tracking of workflow progress and performance |
| 118 | +- **Error Reporting**: Detailed error analysis and debugging capabilities |
| 119 | +- **Performance Analytics**: Metrics for optimization and capacity planning |
| 120 | + |
| 121 | +Let's build your first enterprise-ready AI workflow! 🚀 |
| 122 | + |
| 123 | +## 💻 Running the Code |
| 124 | + |
| 125 | +The complete implementation is available in `01.dotnet-agent-framework-workflow-ghmodel-basic.cs`. This file demonstrates: |
| 126 | + |
| 127 | +1. **Environment Configuration** - Loading GitHub Models credentials from `.env` file |
| 128 | +2. **OpenAI Client Setup** - Configuring the client to use GitHub Models endpoint |
| 129 | +3. **Agent Creation** - Defining specialized agents (Front Desk and Concierge) |
| 130 | +4. **Workflow Builder** - Creating a multi-agent workflow with sequential processing |
| 131 | +5. **Workflow Execution** - Running the workflow with streaming results |
| 132 | + |
| 133 | +### 🚀 Running the Example |
| 134 | + |
| 135 | +```bash |
| 136 | +# Make the script executable (Unix/Linux/macOS) |
| 137 | +chmod +x 01.dotnet-agent-framework-workflow-ghmodel-basic.cs |
| 138 | + |
| 139 | +# Run the workflow |
| 140 | +./01.dotnet-agent-framework-workflow-ghmodel-basic.cs |
| 141 | +``` |
| 142 | + |
| 143 | +Or on Windows: |
| 144 | +```powershell |
| 145 | +dotnet run 01.dotnet-agent-framework-workflow-ghmodel-basic.cs |
| 146 | +``` |
| 147 | + |
| 148 | +### 📝 Expected Output |
| 149 | + |
| 150 | +The workflow will: |
| 151 | +1. Accept your travel destination request ("I would like to go to Paris") |
| 152 | +2. The Front Desk agent provides an initial recommendation |
| 153 | +3. The Concierge agent reviews and refines the recommendation |
| 154 | +4. Final output displays the complete conversation stream |
| 155 | + |
| 156 | +### 🔧 Customization |
| 157 | + |
| 158 | +You can customize the workflow by: |
| 159 | +- Modifying agent instructions to change their behavior |
| 160 | +- Adding more agents to create complex multi-step workflows |
| 161 | +- Changing the user message to test different scenarios |
| 162 | +- Adjusting the workflow edges to create different execution patterns |
0 commit comments