WIP. runs all executors/agents in workflow sequantially.

This commit is contained in:
Shyju Krishnankutty
2026-01-14 12:34:10 -08:00
parent 4340f37e97
commit 7f22a87a24
9 changed files with 288 additions and 18 deletions
@@ -9,6 +9,7 @@ using Microsoft.Agents.AI.Workflows;
using Microsoft.Azure.Functions.Worker.Builder;
using Microsoft.Extensions.Hosting;
using OpenAI.Chat;
using SingleAgent;
// Get the Azure OpenAI endpoint and deployment name from environment variables.
string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
@@ -25,21 +26,40 @@ AzureOpenAIClient client = !string.IsNullOrEmpty(azureOpenAiKey)
// Set up an AI agent following the standard Microsoft Agent Framework pattern.
const string JokerName = "Joker";
const string JokerInstructions = "You are good at telling jokes.";
const string AnalysisInstructions = @"You are a Customer Feedback Analyzer. Your task is to analyze customer survey responses and categorize them accurately.
INPUT: You will receive customer feedback text that may include a rating and comments.
OUTPUT: Return ONLY ONE category from this list:
- Bug Report
- General Feedback
- Billing Question
- Support Incident Status
CATEGORIZATION RULES:
- ""Bug Report"": Technical issues, errors, crashes, features not working as expected
- ""General Feedback"": Suggestions, compliments, general comments about the product or service
- ""Billing Question"": Payment issues, subscription inquiries, pricing questions, refund requests
- ""Support Incident Status"": Follow-ups on existing tickets, status inquiries about previous issues
RESPONSE FORMAT: Return only the category name exactly as shown above, with no additional text or explanation.
Examples:
- ""The app crashes when I try to export"" → Bug Report
- ""Love the new design! Great work"" → General Feedback
- ""Why was I charged twice this month?"" → Billing Question
- ""What's the status of ticket #12345?"" → Support Incident Status";
AIAgent agent = client.GetChatClient(deploymentName).CreateAIAgent(JokerInstructions, JokerName);
AIAgent agent2 = client.GetChatClient(deploymentName).CreateAIAgent("You are good at telling inspirational quotes.", "InspirationBot");
AIAgent agent2 = client.GetChatClient(deploymentName).CreateAIAgent(AnalysisInstructions, "FeedbackAnalysisBot");
Func<string, string> uppercaseFunc = s => s.ToUpperInvariant();
var uppercase = uppercaseFunc.BindAsExecutor("UppercaseExecutor");
SurveyResponseParserExecutor surveyResponseParserExecutor = new();
ResponseRouterExecutor responseRouterExecutor = new();
Func<string, string> reverseTextFunc = s => s.ToUpperInvariant();
var reverse = reverseTextFunc.BindAsExecutor("ReverseTextExecutor");
WorkflowBuilder builder = new(surveyResponseParserExecutor);
builder.AddEdge(surveyResponseParserExecutor, agent2);
builder.AddEdge(agent2, responseRouterExecutor).WithOutputFrom(responseRouterExecutor);
WorkflowBuilder builder = new(uppercase);
builder.AddEdge(uppercase, agent2);
builder.AddEdge(agent2, reverse).WithOutputFrom(agent2);
var workflow = builder.WithName("MyTestWorkflow").Build();
var workflow = builder.WithName("HandleSurveyResponse").Build();
// Configure the function app to host AI agents and workflows in a unified way.
// This will automatically generate HTTP API endpoints for agents and workflows.
@@ -49,7 +69,7 @@ using IHost app = FunctionsApplication
//.ConfigureDurableAgents(op => op.AddAIAgent(agent, timeToLive: TimeSpan.FromHours(1)))
.ConfigureDurableOptions(options =>
{
// Configure workflows - agents referenced in workflows are automatically registered!
// Configure workflows
options.Workflows.AddWorkflow(workflow);
})
.Build();