Notebooks
M
Microsoft
03.Dotnet Agent Framework Workflow Ghmodel Concurrent

03.Dotnet Agent Framework Workflow Ghmodel Concurrent

agentic-aiworkflows-agent-frameworkdotnetai-agents-frameworkcode_samplesagentic-RAGagentic-framework08-multi-agentsemantic-kernelmicrosoft-ai-agents-for-beginnersgenerative-aiai-agentsautogen

⚡ Concurrent Agent Workflows with GitHub Models (.NET)

📋 High-Performance Parallel Processing Tutorial

This notebook demonstrates concurrent workflow patterns using the Microsoft Agent Framework for .NET and GitHub Models. You'll learn how to build high-performance, parallel processing workflows that maximize throughput by executing multiple AI agents simultaneously while maintaining coordination and data consistency.

🎯 Learning Objectives

🚀 Concurrent Processing Fundamentals

  • Parallel Agent Execution: Run multiple AI agents simultaneously for maximum performance
  • Async/Await Patterns: Leverage .NET's async programming model for efficient concurrency
  • GitHub Models Integration: Coordinate multiple concurrent calls to GitHub's AI model inference service
  • Resource Management: Efficiently manage AI model resources across concurrent operations

🏗️ Advanced Concurrency Architecture

  • Task-Based Parallelism: Use .NET Task Parallel Library for optimal concurrent execution
  • Synchronization Patterns: Coordinate concurrent agents while avoiding race conditions
  • Load Balancing: Distribute work efficiently across available concurrent processing capacity
  • Fault Tolerance: Handle individual agent failures without stopping the entire workflow

🏢 Enterprise Concurrent Applications

  • High-Volume Document Processing: Process multiple documents simultaneously
  • Real-Time Content Analysis: Concurrent analysis of incoming data streams
  • Batch Processing Optimization: Maximize throughput for large-scale data processing operations
  • Multi-Modal Analysis: Parallel processing of different content types and formats

⚙️ Prerequisites & Setup

📦 Required NuGet Packages

Essential packages for high-performance concurrent workflows:

<!-- Core AI Framework with Async Support -->
<PackageReference Include="Microsoft.Extensions.AI" Version="9.9.0" />

<!-- Client Model Abstractions for API Communication -->
<PackageReference Include="System.ClientModel" Version="1.6.1.0" />

<!-- Azure Identity and Async LINQ for Advanced Operations -->
<PackageReference Include="Azure.Identity" Version="1.15.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />

<!-- Local Agent Framework References -->
<!-- Microsoft.Agents.AI.dll - Core agent abstractions with async support -->
<!-- Microsoft.Agents.AI.OpenAI.dll - GitHub Models integration with concurrency -->

🔑 GitHub Models Configuration

Environment Setup (.env file):

GITHUB_TOKEN=your_github_personal_access_token
GITHUB_ENDPOINT=https://models.inference.ai.azure.com
GITHUB_MODEL_ID=gpt-4o-mini

Concurrent Processing Considerations:

// Configure for concurrent operations
var clientOptions = new OpenAIClientOptions()
{
    Endpoint = new Uri(githubEndpoint),
    // Configure connection pooling for concurrent requests
    NetworkTimeout = TimeSpan.FromMinutes(5)
};

🏗️ Concurrent Workflow Architecture

Rendering diagram...

Key Components:

  • Task Parallel Library: .NET's built-in support for concurrent operations
  • Agent Pool: Multiple agent instances for parallel processing
  • Result Aggregation: Coordination and merging of concurrent agent results
  • Synchronization Points: Ensure data consistency across concurrent operations

🎨 Concurrent Workflow Design Patterns

🔍 Parallel Research & Analysis

Research Topic → Concurrent Research Agents → Result Synthesis → Final Report

📊 Multi-Source Data Processing

Data Sources → Parallel Processing Agents → Data Integration → Unified Output

🎭 Content Generation Pipeline

Content Requirements → Concurrent Content Generators → Quality Review → Final Content

🔄 Fan-Out/Fan-In Processing

Single Input → Multiple Concurrent Processors → Result Aggregation → Single Output

🏢 Enterprise Performance Benefits

Throughput & Scalability

  • Linear Performance Scaling: Add more concurrent agents to increase throughput
  • Resource Utilization: Maximum efficiency of available AI model capacity
  • Reduced Processing Time: Significant time reduction through parallel execution
  • Elastic Scaling: Dynamically adjust concurrent agent count based on workload

🛡️ Reliability & Resilience

  • Fault Isolation: Individual agent failures don't affect other concurrent operations
  • Graceful Degradation: System continues operating with reduced agent capacity
  • Error Recovery: Automatic retry mechanisms for failed concurrent operations
  • Load Distribution: Even distribution of work across available agents

📊 Performance Monitoring

  • Concurrent Execution Metrics: Track performance of all parallel operations
  • Resource Usage Analytics: Monitor CPU, memory, and network utilization
  • Throughput Analysis: Measure efficiency gains from concurrent processing
  • Bottleneck Detection: Identify and resolve performance constraints

🔧 Development & Operations

  • Async Programming Model: Leverage .NET's mature async/await patterns
  • Task Coordination: Built-in task management and coordination capabilities
  • Exception Handling: Comprehensive error handling for concurrent operations
  • Debugging Support: Visual Studio debugging tools for concurrent workflows

Let's build high-performance concurrent AI workflows with .NET! 🚀

[1]
[2]
[3]
[4]
[ ]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
[16]
[17]
[18]
[19]
[20]
Workflow completed with results:
Plan-Agent: December is a magical time to visit Seattle, as the city embraces the festive season with sparkling holiday lights, seasonal activities, cozy indoor attractions, and hearty cuisine. The weather will be chilly, often rainy, and occasionally snowy, so pack accordingly. Here's a detailed trip plan for your Seattle visit:

---

### **Travel Dates**  
Suggested schedule: **3-5 days in Seattle (example: December 15–19)**  
Adjust according to your preferences and availability.

---

### **Packing Essentials**  
- Warm, waterproof coat  
- Umbrella or rain jacket (Seattle has rainy winters)  
- Waterproof boots or shoes  
- Layers: sweaters, thermal tops, scarves, gloves, and hats  
- Day backpack for exploring  
- Travel charger and portable power bank  
- Camera or phone for holiday photos  

---

### **Day 1: Arrival and Exploring Downtown**  
**Morning**  
- Arrive at **Seattle-Tacoma International Airport (SEA)**.  
- Transfer to your accommodation (stay downtown for convenience). Options:  
  - Luxury: **The Four Seasons Seattle**  
  - Boutique: **The Hotel Andra**  
  - Budget-friendly: **The Mediterranean Inn**  

**Afternoon**  
- Lunch at **Elliott’s Oyster House** near the waterfront for fresh seafood.  
- Begin exploring **Pike Place Market**.  
  - Shop artisan goods and seasonal items.  
  - Watch the famous fishmongers toss fish.  
  - Grab a cup of coffee from the original **Starbucks** store (if the line isn't too long).  

**Evening**  
- Stroll along the **Seattle Waterfront** and explore the festive lights in **Waterfront Park**.  
- Enjoy dinner at **Canlis** for a fine dining experience or **Toulouse Petit** for flavorful Cajun/Creole cuisine.  

---

### **Day 2: Iconic Attractions and Holiday Cheer**  
**Morning**  
- Visit the **Space Needle** first thing for stunning views of the city and Mount Rainier (on clear days).  
- Explore the **Chihuly Garden and Glass** exhibit nearby for mesmerizing art.  

**Afternoon**  
- Head to **Museum of Pop Culture (MoPOP)** for interactive exhibits covering music, gaming, sci-fi, and pop culture.  
- Grab lunch at **The Pink Door**, an Italian-American restaurant with festive vibes.  

**Evening**  
- Discover the **Seattle Center Winterfest**. It features:  
  - Ice skating  
  - Holiday music performances  
  - Winter-themed light displays  
- Dinner at **Serious Pie** for wood-fired pizza or **Mashiko** if you're craving sushi.  

---

### **Day 3: Day Trips and Nature**  
**Morning**  
- Take a short day trip to **Snoqualmie Falls** (about 40 minutes east of downtown Seattle).  
  - Walk the scenic observation trails for stunning views of the waterfalls amidst wintry landscapes.  

**Afternoon**  
- Return to Seattle and warm up with lunch at **Matt’s in the Market** (great views and hearty food downtown).  
- Visit **Kerry Park** for postcard-worthy skyline views, especially during the holidays when lights sparkle across the city.  

**Evening**  
- Return to downtown and enjoy the holiday markets, such as **Downtown Holiday Lights & Market** (check for seasonal pop-ups).  
- Dinner and drinks at **The Nest**, a rooftop bar offering panoramic views of the waterfront.  

---

### **Day 4: Unique Neighborhoods and Relaxing**  
**Morning**  
- Take a stroll through **Capitol Hill**, a trendy neighborhood.  
  - Have brunch at **Tilikum Place Café** or **Tallulah’s**.  
  - Explore local shops and bookstores like **Elliott Bay Book Company**.  

**Afternoon**  
- Take a relaxing afternoon ferry ride to **Bainbridge Island**.  
  - Walk around charming boutiques and coffee shops.  
  - Visit the scenic **Bloedel Reserve**, a stunning garden combining nature and holiday tranquility.  

**Evening**  
- Catch a live holiday-themed performance. Options include:  
  - **The Nutcracker** by the Pacific Northwest Ballet  
  - A Christmas show at **The Paramount Theatre**  

Have your last dinner in Seattle at **Revolver Bar** or **Etta’s**, located near the waterfront.

---

### **Day 5: Departure**  
**Morning**  
- Stop at **Seattle Coffee Works** or **Café Ladro** for your last dose of Seattle coffee culture.  
- Souvenir shopping at **Ye Olde Curiosity Shop** for unique keepsakes.  
- Head to the airport for your flight home.  

---

### **Transportation**  
- **Getting Around**:  
  - Utilize Seattle’s excellent public transit system (Link Light Rail, buses, and streetcars).  
  - Rideshare options like Uber/Lyft are readily available.  
  - Rent a car only if planning day trips outside the city (e.g., Snoqualmie Falls).  

---

### **Budget Considerations**  
- **Accommodations**: $150–$400 per night (depending on preferences)  
- **Food**: $60–$100/day per person  
- **Activities** (tickets): $50–$100/day  
- **Transportation**: $10–$20/day for public transit/rideshares  

---

### **Extra Notes**
- Make restaurant reservations for popular spots, especially during the holidays.  
- Seattle weather can change rapidly, so keep an umbrella or raincoat with you at all times.  
- Be mindful of the shorter daylight hours in December.  

Enjoy the cozy vibes, festive activities, and breathtaking views that Seattle offers in December! Let me know if you'd like more suggestions.
Researcher-Agent: Seattle in December is a wonderful destination with its mix of urban charm, holiday festivities, and nearby natural beauty. While the weather may be chilly (averaging 40°F–47°F with rain), the city’s attractions and seasonal events provide plenty to enjoy. Below, I’ll outline an itinerary and highlight key destinations to make the most of your trip. 

---

### **Day 1: Downtown Seattle Exploration**
1. **Pike Place Market**  
   - **Why Visit?** Seattle’s iconic landmark, filled with local food vendors, artisanal goods, and street performers. Don’t miss the famous fish toss and the original Starbucks store.  
   - **Things to Do**: Browse the market, enjoy lunch at Beecher’s Handmade Cheese or Piroshky Piroshky, and stop at the market’s waterfront for views of Elliott Bay.  
   - **Seasonal Note**: Holiday decorations make this area festive! Look for vendors selling seasonal handicrafts.  

2. **Seattle Aquarium**  
   - **Why Visit?** Located nearby on the waterfront, the aquarium offers interactive exhibits about marine life from the Pacific Northwest.  
   - **Things to Do**: Explore exhibits like the underwater dome, touch tanks with sea stars, and learn about marine conservation.  

3. **Waterfront and Great Wheel**  
   - **Why Visit?** The Seattle Great Wheel, one of the largest Ferris wheels on the West Coast, offers panoramic views of the city, Puget Sound, and mountains.  
   - **Things to Do**: Take a ride on the Great Wheel (especially stunning at twilight), explore the waterfront area, and check out shops or restaurants such as Ivar’s Seafood Bar.  

---

### **Day 2: Iconic Landmarks & Museums**  
1. **Space Needle**  
   - **Why Visit?** This famous tower offers 360-degree views of Seattle, including Mt. Rainier, Puget Sound, and the Olympic and Cascade mountain ranges.  
   - **Things to Do**: Visit the observation deck, take photos of the city skyline, and grab food at the café if desired.  
   - **Seasonal Note**: The views may include snow-capped mountains if the weather is clear.  

2. **Chihuly Garden and Glass**  
   - **Why Visit?** A visually stunning museum featuring Dale Chihuly's unique glass sculptures.  
   - **Things to Do**: Walk through the glasshouse, gardens, and indoor exhibits to marvel at the artistry of blown glass installations.  

3. **Museum of Pop Culture (MoPOP)**  
   - **Why Visit?** A vibrant museum on creativity and entertainment, perfect for pop culture enthusiasts.  
   - **Things to Do**: Explore exhibits on music (like the Nirvana gallery), science fiction, film, gaming, and more.  

4. **Holiday Festivities in Seattle Center**  
   - **Why Visit?** Seattle Center often hosts holiday-themed events in December, like evening light shows and performances. Check out the Winterfest activities, including ice skating at the Seattle Center Armory.  

---

### **Day 3: Nature & Surrounding Areas**  
1. **Discovery Park**  
   - **Why Visit?** Seattle’s largest green space, offering tranquil beaches, forested trails, and stunning views of Puget Sound and the Olympic Mountains.  
   - **Things to Do**: Hike the trails, walk to the West Point Lighthouse, and enjoy the fresh air with gorgeous coastal scenery.  

2. **Fremont Neighborhood**  
   - **Why Visit?** Known as the “Center of the Universe,” this quirky neighborhood offers boutique shops, great restaurants, art, and attractions.  
   - **Things to Do**: See the Fremont Troll under the Aurora Bridge, shop local stores, and dine at neighborhood favorites like Revel or Joule.  

3. **Gas Works Park**  
   - **Why Visit?** A scenic spot for city skyline views. The historic gas plant structures make this park unique.  
   - **Things to Do**: Take photos of the skyline at sunset, have a winter picnic, or simply enjoy the panoramic city-bay views.  

---

### **Day 4: Day Trip to Mount Rainier or Leavenworth**  
1. **Option 1: Mount Rainier National Park**  
   - **Why Visit?** Located about 2 hours from Seattle, this stunning national park offers winter scenery, snowshoeing, and peaceful landscapes.  
   - **Things to Do**: Book a snowshoe tour, visit Paradise for picturesque winter views, and soak in the serenity of nature.  

2. **Option 2: Leavenworth Christmas Village**  
   - **Why Visit?** About 2.5 hours away, Leavenworth is an alpine-style Bavarian village that transforms into a winter wonderland in December.  
   - **Things to Do**: Stroll through the Christmas-lit village, shop for holiday gifts, enjoy German-inspired food and drinks (like bratwurst and glühwein), and check out sleigh rides or sledding opportunities.  

---

### **Optional Activities (in case you extend your stay)**  
- **Pacific Northwest Ballet: "The Nutcracker"**  
   - Why Visit? A quintessential holiday favorite, performed beautifully in Seattle each December.  
- **Woodinville Wine Country** (day trip)  
   - Why Visit? Sip on world-class wines at charming wineries just 30 minutes northeast of Seattle.

---

### Packing Tips for December Seattle Visit:  
1. **Clothing**: Waterproof jacket, warm layers, scarves, and comfortable walking shoes.  
2. **Gear**: Umbrella or hooded raincoat (Seattle is rainy in December!), and a camera for capturing holiday decorations and scenic vistas.

This itinerary blends Seattle’s iconic landmarks, holiday spirit, and nearby natural wonders for a memorable December trip! Let me know if you'd like me to refine or customize further.