microsoft/autogen · error · ArgumentException

No name is returned.

Error message

No name is returned.

What it means

In the obsolete SelectNextSpeakerAsync, after asking the admin to name the next speaker, the code reads response.GetContent() and throws ArgumentException('No name is returned.') if content is null. It then blindly Substring(5) to strip 'From ' and matches agents by lowercased name. Null or non-conforming content (empty reply, function-call response, refusal) therefore crashes either at this throw or the substring/match step.

Source

Thrown at dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs:156

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

        var conv = this.ProcessConversationsForRolePlay(this.initializeMessages, conversationHistory);

        var messages = new IMessage[] { systemMessage }.Concat(conv);
        var response = await this.admin.GenerateReplyAsync(
            messages: messages,
            options: new GenerateReplyOptions
            {
                Temperature = 0,
                MaxToken = 128,
                StopSequence = [":"],
                Functions = [],
            });

        var name = response?.GetContent() ?? throw new ArgumentException("No name is returned.");

        // remove From
        name = name!.Substring(5);
        return this.agents.First(x => x.Name!.ToLower() == name.ToLower());
    }

    /// <inheritdoc />
    public void AddInitializeMessage(IMessage message)
    {
        this.SendIntroduction(message);
    }

    public async Task<IEnumerable<IMessage>> CallAsync(
        IEnumerable<IMessage>? chatHistory = null,
        int maxRound = 10,
        CancellationToken ct = default)
    {
        var conversationHistory = new List<IMessage>();

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Give the admin a clear system prompt and simple candidate names (single lowercase tokens) so it reliably replies 'From <name>:'.
  2. Pass GenerateReplyOptions with Temperature 0 and stop sequence ':' (the code already does) and use a strong instruct model for the admin.
  3. Disable function calling / tools on the admin agent so the reply is plain text content.
  4. Wrap the call in try/catch for ArgumentException/InvalidOperationException and retry selection or fall back to round-robin.

Example fix

// before
var next = await chat.SelectNextSpeakerAsync(speaker, history);

// after
IAgent next;
try
{
    next = await chat.SelectNextSpeakerAsync(speaker, history);
}
catch (ArgumentException)
{
    // admin reply was null or malformed; default to round-robin
    next = members[(currentIndex + 1) % members.Count];
}
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    return await chat.SelectNextSpeakerAsync(speaker, history);
}
catch (ArgumentException ex) when (ex.Message.Contains("No name is returned"))
catch (InvalidOperationException) // agent name not found after Substring(5)
{
    return roundRobinNext(speaker); // deterministic fallback
}

Prevention

When it happens

Trigger: Admin agent returns null content (e.g. a ToolCallMessage or empty completion); admin ignores the role-play format and replies without the 'From name:' prefix; admin hallucinates a name not in the candidate list (then First() throws InvalidOperationException instead).

Common situations: Admin model too weak to follow the 'From <name>:' format; temperature or stop-sequence settings truncating the reply at ':'; admin configured with function-calling enabled so GetContent() is null; candidate names the model tends to mangle (spaces, casing).

Related errors


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