microsoft/autogen · error · ArgumentException
The response from admin is {name}, which is either not in th
Error message
The response from admin is {name}, which is either not in the candidates list or not in the correct format. What it means
Thrown by RolePlayOrchestrator.GetNextSpeakerAsync when the admin's extracted speaker name (after stripping the 5-character 'From ' prefix) does not case-insensitively match any candidate agent name. The exception message embeds the raw parsed name to show what the admin actually said.
Source
Thrown at dotnet/src/AutoGen.Core/Orchestrator/RolePlayOrchestrator.cs:101
MaxToken = 128,
StopSequence = [":"],
Functions = null,
},
cancellationToken: cancellationToken);
var name = response.GetContent() ?? throw new ArgumentException("No name is returned.");
// remove From
name = name!.Substring(5);
var candidate = candidates.FirstOrDefault(x => x.Name!.ToLower() == name.ToLower());
if (candidate != null)
{
return candidate;
}
var errorMessage = $"The response from admin is {name}, which is either not in the candidates list or not in the correct format.";
throw new ArgumentException(errorMessage);
}
private IEnumerable<IMessage> ProcessConversationsForRolePlay(IEnumerable<IMessage> messages)
{
return messages.Select((x, i) =>
{
var msg = @$"From {x.From}:
{x.GetContent()}
<eof_msg>
round # {i}";
return new TextMessage(Role.User, content: msg);
});
}
}
View on GitHub (pinned to 027ecf0a37)
Solutions
- Make agent names simple single tokens (no spaces/punctuation) matching what the admin prompt shows
- Strengthen the admin's system prompt to reply exactly 'From <agentname>:' and nothing else
- Lower Temperature is already 0; also consider raising MaxToken and few-shot examples in the role-play prompt
- Catch ArgumentException around GetNextSpeakerAsync and retry the round, or implement a custom IOrchestrator with fuzzy name matching
Example fix
// before: agents named "Code Reviewer Expert" -> admin replies 'From Code Reviewer Expert:' butSubstring may misalign // after: use single-token names var alice = new AssistantAgent(name: "alice", ...); var bob = new AssistantAgent(name: "bob", ...);
Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check candidate names are single tokens the LLM can echo exactly
if (candidates.Any(c => c.Name!.Contains(' ') || c.Name!.Length < 2))
throw new InvalidOperationException("Rename agents to single-token names before role-play orchestration"); Try / catch
for (int attempt = 0; attempt < 3; attempt++)
{
try { return await orchestrator.GetNextSpeakerAsync(ctx, ct); }
catch (ArgumentException e) when (e.Message.Contains("not in the candidates list") && attempt < 2)
{ /* temperature-0 retry; LLM format drift is often transient */ }
} Prevention
- Use simple lowercase single-word agent names
- Instruct the admin explicitly: reply with 'From <name>:' only
- Consider a custom orchestrator that fuzzy-matches admin output to candidate names
When it happens
Trigger: Admin reply format deviates from 'From <name>:' — e.g. 'From alice smith:', a name with trailing punctuation, a hallucinated agent not in the candidates list, or content shorter than 5 characters (note: Substring(5) itself would throw ArgumentOutOfRangeException first for short strings).
Common situations: Prompt drift where the LLM answers with a sentence instead of a name, agent names containing spaces/casing mismatching the prompt example, stop-sequence ':' behaving differently across model providers, or candidates list changing between rounds.
Related errors
- No name is returned.
- No coder message found
- Failed to review code block
- No user message found.
- Please set OPENAI_API_KEY environment variable.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/51a8f79c88650b86.
Report an issue: GitHub.