microsoft/autogen · error · InvalidOperationException
ResultsPerPrompt greater than 1 is not supported in this sem
Error message
ResultsPerPrompt greater than 1 is not supported in this semantic kernel agent
What it means
SemanticKernelAgent.GenerateReplyAsync throws this when the underlying IChatCompletionService returns more than one ChatMessageContent. The agent maps GenerateReplyOptions.ResultsPerPrompt into the kernel's PromptExecutionSettings, but its return type (a single IMessage) can only carry one reply, so multiple results are treated as unsupported.
Source
Thrown at dotnet/src/AutoGen.SemanticKernel/SemanticKernelAgent.cs:72
this.Name = name;
_systemMessage = systemMessage;
_modelServiceId = modelServiceId;
_settings = settings;
}
public string Name { get; }
public async Task<IMessage> GenerateReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default)
{
var chatHistory = BuildChatHistory(messages);
var option = BuildOption(options);
var chatService = GetChatCompletionService();
var reply = await chatService.GetChatMessageContentsAsync(chatHistory, option, _kernel, cancellationToken);
if (reply.Count > 1)
{
throw new InvalidOperationException("ResultsPerPrompt greater than 1 is not supported in this semantic kernel agent");
}
return new MessageEnvelope<ChatMessageContent>(reply[0], from: this.Name);
}
public async IAsyncEnumerable<IMessage> GenerateStreamingReplyAsync(
IEnumerable<IMessage> messages,
GenerateReplyOptions? options = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var chatHistory = BuildChatHistory(messages);
var option = BuildOption(options);
var chatService = GetChatCompletionService();
var response = chatService.GetStreamingChatMessageContentsAsync(chatHistory, option, _kernel, cancellationToken);
await foreach (var content in response)
{
if (content.ChoiceIndex > 0)View on GitHub (pinned to 027ecf0a37)
Solutions
- Set ResultsPerPrompt = 1 (or leave it null/default) in the GenerateReplyOptions passed to the SemanticKernel agent
- If multiple candidates are genuinely needed, call the kernel's IChatCompletionService directly instead of going through SemanticKernelAgent
- Do not reuse an options object configured for another provider's multi-choice behavior
Example fix
// before
var options = new GenerateReplyOptions { Temperature = 0.7f, ResultsPerPrompt = 3 };
var reply = await skAgent.GenerateReplyAsync(messages, options);
// after
var options = new GenerateReplyOptions { Temperature = 0.7f, ResultsPerPrompt = 1 };
var reply = await skAgent.GenerateReplyAsync(messages, options); Defensive patterns
Strategy: validation
Validate before calling
if (options?.ResultsPerPrompt is > 1)
{
options = options with { ResultsPerPrompt = 1 }; // or throw your own config error early
} Type guard
static bool IsSingleChoice(GenerateReplyOptions? o) => o?.ResultsPerPrompt is null or 1;
Try / catch
try { return await skAgent.GenerateReplyAsync(messages, options); }
catch (InvalidOperationException ex) when (ex.Message.Contains("ResultsPerPrompt"))
{
throw new ConfigurationException("SemanticKernel agent requires ResultsPerPrompt=1", ex);
} Prevention
- Never share an options object configured with n>1 across agent implementations
- Assert single-choice options in integration tests for SK agents
- Centralize option construction per provider instead of one global template
When it happens
Trigger: Calling GenerateReplyAsync with a GenerateReplyOptions whose ResultsPerPrompt (or the kernel execution settings' ResultsPerPrompt / ChoiceCount) is greater than 1, against a connector that honors n>1.
Common situations: Copying options from an OpenAI agent configuration that sets n>1 for sampling variety, a model/connector version that started respecting ResultsPerPrompt, or sharing one options object across different agent types.
Related errors
- ResultsPerPrompt greater than 1 is not supported in this sem
- Unsupported message type
- Only one choice is supported in streaming response
- Please set OPENAI_API_KEY environment variable.
- Missing parameter type for {parameterName}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/74ef703a488772dd.
Report an issue: GitHub.