Timeout issue when running Orchestration with multiple agents #13186
Replies: 2 comments
-
@ShinjiCodeEVA I ran into the same problem yesterday. As a workaround, try using AzureCliCredential instead of the API key when calling AddAzureOpenAIChatCompletion() on the Semantic Kernel Builder. Interestingly, when using an API key in the SK builder for ChatCompletionService, it works fine, but when trying to use ChatCompletionAgent, it doesn't. Test code// Add references
using Azure.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Orchestration.Sequential;
using Microsoft.SemanticKernel.Agents.Runtime.InProcess;
using Microsoft.SemanticKernel.ChatCompletion;
internal class Program
{
private const string ServiceId = "aoai";
public static async Task Main()
{
// Clear the console
Console.Clear();
// Get configuration settings
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
var deployment = Environment.GetEnvironmentVariable("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME");
var apiVersion = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_VERSION");
if (string.IsNullOrWhiteSpace(endpoint) || string.IsNullOrWhiteSpace(apiKey) || string.IsNullOrWhiteSpace(deployment) || string.IsNullOrEmpty(apiVersion))
{
Console.Error.WriteLine("Brak wymaganych zmiennych środowiskowych: AZURE_OPENAI_ENDPOINT / AZURE_OPENAI_API_KEY / AZURE_OPENAI_DEPLOYMENT / AZURE_OPENAI_API_VERSION.");
return;
}
var builder = Kernel.CreateBuilder();
// Add logging for verification
builder.Services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Debug));
// Registering the Azure OpenAI connector
builder.AddAzureOpenAIChatCompletion(
deploymentName: deployment,
endpoint: endpoint
//,apiKey: apiKey //if with API key then ChatCompletionService works but ChatCompletionAgent does not
,new AzureCliCredential()
,serviceId: ServiceId);
var kernel = builder.Build();
// Checking the connection for ChatCompletion service
var pingService = kernel.GetRequiredService<IChatCompletionService>(ServiceId);
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await pingService.GetChatMessageContentAsync("ping", cancellationToken: cts.Token);
// Create a summarizer agent
var summarizerAgent = new ChatCompletionAgent
{
Name = "SummarizerAgent",
Description = "An agent that summarize the customer's feedback ",
Instructions =
"""
Summarize the customer's feedback in one short sentence. Keep it neutral and concise.
Example output:
App crashes during photo upload.
User praises dark mode feature.
"""
,Kernel = kernel
,Arguments = new KernelArguments(new PromptExecutionSettings
{
ServiceId = ServiceId,
})
};
// Create a classifier agent
var classifierAgent = new ChatCompletionAgent
{
Name = "ClassifierAgent",
Description = "An agent that classify the feedback",
Instructions =
"""
Classify the feedback as one of the following: Positive, Negative, or Feature request.
"""
,Kernel = kernel
,Arguments = new KernelArguments(new PromptExecutionSettings
{
ServiceId = ServiceId,
})
};
// Create a recommmended action agent
var actionAgent = new ChatCompletionAgent
{
Name = "ActionAgent",
Description = "An agent that suggest the next action",
Instructions =
"""
Based on the summary and classification, suggest the next action in one short sentence.
Example output:
Escalate as a high-priority bug for the mobile team.
Log as positive feedback to share with design and marketing.
Log as enhancement request for product backlog.
"""
,Kernel = kernel
,Arguments = new KernelArguments(new PromptExecutionSettings
{
ServiceId = ServiceId
})
};
ValueTask AgentResponseCallback(ChatMessageContent response)
{
Console.WriteLine($"# {response.AuthorName}\n{response.Content}");
return ValueTask.CompletedTask;
}
// Create a sequential orchestration with a response callback to observe the output from each agent.
var orchestration = new SequentialOrchestration(summarizerAgent, classifierAgent, actionAgent)
{
ResponseCallback = AgentResponseCallback
};
var runtime = new InProcessRuntime();
await runtime.StartAsync();
// Initialize the input task
var task =
"""
I tried updating my profile picture several times today, but the app kept freezing halfway through the process.
I had to restart it three times, and in the end, the picture still wouldn't upload.
It's really frustrating and makes the app feel unreliable.
""";
// Invoke the orchestration with a task and the runtime
var orchestrationResult = await orchestration.InvokeAsync(
input: task,
runtime: runtime
);
// Wait for the results
var value = await orchestrationResult.GetValueAsync(TimeSpan.FromSeconds(30));
Console.WriteLine($"\n****** Task Input ******\n{task}");
Console.WriteLine($"\n***** Final Result *****\n{value}");
// Stop the runtime when idle
await runtime.RunUntilIdleAsync();
Console.ReadLine();
}
} |
Beta Was this translation helpful? Give feedback.
-
Same issue here also SOLUTION = DON'T LEAVE Description empty ChatCompletionAgent analystAgent = new ChatCompletionAgent { |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi team 👋,
I’m experimenting with the new agent orchestration APIs in Semantic Kernel and ran into a problem where my orchestration never completes — it times out even though I expected a single pass through the agents.
Error
Unhandled exception. System.TimeoutException: Orchestration did not complete within the allowed duration (00:01:00).
$(String[] args) in C:\Users\Harvie\source\repos\DotnetSemanticKernel\AgentOrchestration\Program.cs:line 46at Microsoft.SemanticKernel.Agents.Orchestration.OrchestrationResult
1.GetValueAsync(Nullable
1 timeout, CancellationToken cancellationToken)at Program.
at Program.(String[] args)
Repro code
Beta Was this translation helpful? Give feedback.
All reactions