{"record":{"id":"fe78cfaeeb0bc2b6","repo":"microsoft/autogen","slug":"no-name-is-returned","errorCode":null,"errorMessage":"No name is returned.","messagePattern":"No name is returned\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs","lineNumber":156,"sourceCode":"\nEach message will start with 'From name:', e.g:\nFrom {agentNames.First()}:\n//your message//.\");\n\n        var conv = this.ProcessConversationsForRolePlay(this.initializeMessages, conversationHistory);\n\n        var messages = new IMessage[] { systemMessage }.Concat(conv);\n        var response = await this.admin.GenerateReplyAsync(\n            messages: messages,\n            options: new GenerateReplyOptions\n            {\n                Temperature = 0,\n                MaxToken = 128,\n                StopSequence = [\":\"],\n                Functions = [],\n            });\n\n        var name = response?.GetContent() ?? throw new ArgumentException(\"No name is returned.\");\n\n        // remove From\n        name = name!.Substring(5);\n        return this.agents.First(x => x.Name!.ToLower() == name.ToLower());\n    }\n\n    /// <inheritdoc />\n    public void AddInitializeMessage(IMessage message)\n    {\n        this.SendIntroduction(message);\n    }\n\n    public async Task<IEnumerable<IMessage>> CallAsync(\n        IEnumerable<IMessage>? chatHistory = null,\n        int maxRound = 10,\n        CancellationToken ct = default)\n    {\n        var conversationHistory = new List<IMessage>();","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs#L138-L174","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","solutions":["Give the admin a clear system prompt and simple candidate names (single lowercase tokens) so it reliably replies 'From <name>:'.","Pass GenerateReplyOptions with Temperature 0 and stop sequence ':' (the code already does) and use a strong instruct model for the admin.","Disable function calling / tools on the admin agent so the reply is plain text content.","Wrap the call in try/catch for ArgumentException/InvalidOperationException and retry selection or fall back to round-robin."],"exampleFix":"// before\nvar next = await chat.SelectNextSpeakerAsync(speaker, history);\n\n// after\nIAgent next;\ntry\n{\n    next = await chat.SelectNextSpeakerAsync(speaker, history);\n}\ncatch (ArgumentException)\n{\n    // admin reply was null or malformed; default to round-robin\n    next = members[(currentIndex + 1) % members.Count];\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    return await chat.SelectNextSpeakerAsync(speaker, history);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"No name is returned\"))\ncatch (InvalidOperationException) // agent name not found after Substring(5)\n{\n    return roundRobinNext(speaker); // deterministic fallback\n}","preventionTips":["Use simple single-token lowercase agent names so the admin model reproduces them exactly.","Disable function calling on the admin agent so GetContent() is never null.","Use a strong instruct model with temperature 0 for the admin role."],"tags":["autogen","dotnet","group-chat","llm-output-parsing","speaker-selection","argumentexception"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}