microsoft/autogen · error · ArgumentException

No name is returned.

Error message

No name is returned.

What it means

Thrown by RolePlayOrchestrator.GetNextSpeakerAsync when the admin agent, asked to pick the next speaker in a group chat, returns a reply whose GetContent() is null. The orchestrator cannot extract a speaker name, so it throws ArgumentException('No name is returned.').

Source

Thrown at dotnet/src/AutoGen.Core/Orchestrator/RolePlayOrchestrator.cs:89

Each message will start with 'From name:', e.g:
From {agentNames.First()}:
//your message//.");

        var chatHistoryWithName = this.ProcessConversationsForRolePlay(context.ChatHistory);
        var messages = new IMessage[] { rolePlayMessage }.Concat(chatHistoryWithName);

        var response = await this.admin.GenerateReplyAsync(
            messages: messages,
            options: new GenerateReplyOptions
            {
                Temperature = 0,
                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) =>
        {

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Configure the admin agent to always reply with plain text (disable function calling / tool choice on the admin)
  2. Increase MaxToken or adjust the admin's system prompt so it reliably answers with 'From <name>:'
  3. Use an admin whose connector converts any reply into a TextMessage (e.g. wrap with a message connector middleware)
  4. Catch ArgumentException and retry GetNextSpeakerAsync, since LLM non-determinism is involved

Example fix

// before: var admin = agent.WithInstructions("pick next speaker"); // may return tool-call/empty
// after: force text-only admin
var admin = textOnlyAgent.RegisterMiddleware(async (ctx, agent, ct) =>
{
    var reply = await agent.GenerateReplyAsync(ctx.Messages, new GenerateReplyOptions { Functions = null }, ct);
    return new TextMessage(Role.Assistant, reply.GetContent() ?? string.Empty, agent.Name);
});
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check the admin's reply shape is predictable by running one probe turn
var probe = await admin.GenerateReplyAsync(new[] { new TextMessage(Role.User, "Reply with exactly: From <your name>:") }, ct: ct);
if (probe.GetContent() is null) { /* admin not suitable; fix configuration */ }

Type guard

static bool HasTextContent(IMessage reply) => !string.IsNullOrEmpty(reply.GetContent());

Try / catch

try { var next = await orchestrator.GetNextSpeakerAsync(context, ct); }
catch (ArgumentException e) when (e.Message.Contains("No name is returned"))
{ /* retry the round once, or terminate the group chat gracefully */ }

Prevention

When it happens

Trigger: A GroupChat with multiple candidates (and either no workflow or an ambiguous workflow) invokes the admin agent; the admin's reply has null content — e.g. it replied only with a tool call, an empty message, or a non-text payload, because Functions=null does not prevent non-text replies from all agent types.

Common situations: Admin agents that respond with function calls instead of text, connectors that strip content, LLM returning empty content due to content filters or token limits (MaxToken=128), or a misconfigured admin that returns an envelope message.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/07cd20f5c480cc70. Report an issue: GitHub.