{"record":{"id":"07cd20f5c480cc70","repo":"microsoft/autogen","slug":"no-name-is-returned-07cd20","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/Orchestrator/RolePlayOrchestrator.cs","lineNumber":89,"sourceCode":"Each message will start with 'From name:', e.g:\nFrom {agentNames.First()}:\n//your message//.\");\n\n        var chatHistoryWithName = this.ProcessConversationsForRolePlay(context.ChatHistory);\n        var messages = new IMessage[] { rolePlayMessage }.Concat(chatHistoryWithName);\n\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 = null,\n            },\n            cancellationToken: cancellationToken);\n\n        var name = response.GetContent() ?? throw new ArgumentException(\"No name is returned.\");\n\n        // remove From\n        name = name!.Substring(5);\n        var candidate = candidates.FirstOrDefault(x => x.Name!.ToLower() == name.ToLower());\n\n        if (candidate != null)\n        {\n            return candidate;\n        }\n\n        var errorMessage = $\"The response from admin is {name}, which is either not in the candidates list or not in the correct format.\";\n        throw new ArgumentException(errorMessage);\n    }\n\n    private IEnumerable<IMessage> ProcessConversationsForRolePlay(IEnumerable<IMessage> messages)\n    {\n        return messages.Select((x, i) =>\n        {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.Core/Orchestrator/RolePlayOrchestrator.cs#L71-L107","documentation":"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.').","triggerScenarios":"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.","commonSituations":"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.","solutions":["Configure the admin agent to always reply with plain text (disable function calling / tool choice on the admin)","Increase MaxToken or adjust the admin's system prompt so it reliably answers with 'From <name>:'","Use an admin whose connector converts any reply into a TextMessage (e.g. wrap with a message connector middleware)","Catch ArgumentException and retry GetNextSpeakerAsync, since LLM non-determinism is involved"],"exampleFix":"// before: var admin = agent.WithInstructions(\"pick next speaker\"); // may return tool-call/empty\n// after: force text-only admin\nvar admin = textOnlyAgent.RegisterMiddleware(async (ctx, agent, ct) =>\n{\n    var reply = await agent.GenerateReplyAsync(ctx.Messages, new GenerateReplyOptions { Functions = null }, ct);\n    return new TextMessage(Role.Assistant, reply.GetContent() ?? string.Empty, agent.Name);\n});","handlingStrategy":"try-catch","validationCode":"// Pre-check the admin's reply shape is predictable by running one probe turn\nvar probe = await admin.GenerateReplyAsync(new[] { new TextMessage(Role.User, \"Reply with exactly: From <your name>:\") }, ct: ct);\nif (probe.GetContent() is null) { /* admin not suitable; fix configuration */ }","typeGuard":"static bool HasTextContent(IMessage reply) => !string.IsNullOrEmpty(reply.GetContent());","tryCatchPattern":"try { var next = await orchestrator.GetNextSpeakerAsync(context, ct); }\ncatch (ArgumentException e) when (e.Message.Contains(\"No name is returned\"))\n{ /* retry the round once, or terminate the group chat gracefully */ }","preventionTips":["Give the admin a text-forcing configuration (no function calling)","Keep the admin's MaxToken high enough to finish a one-line answer"],"tags":["autogen","group-chat","orchestrator","llm"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}