{"record":{"id":"51a8f79c88650b86","repo":"microsoft/autogen","slug":"the-response-from-admin-is-name-which-is-either","errorCode":null,"errorMessage":"The response from admin is {name}, which is either not in the candidates list or not in the correct format.","messagePattern":"The response from admin is (.+?), which is either not in the candidates list or not in the correct format\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.Core/Orchestrator/RolePlayOrchestrator.cs","lineNumber":101,"sourceCode":"                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        {\n            var msg = @$\"From {x.From}:\n{x.GetContent()}\n<eof_msg>\nround # {i}\";\n\n            return new TextMessage(Role.User, content: msg);\n        });\n    }\n}\n","sourceCodeStart":83,"sourceCodeEnd":117,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.Core/Orchestrator/RolePlayOrchestrator.cs#L83-L117","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before: agents named \"Code Reviewer Expert\" -> admin replies 'From Code Reviewer Expert:' butSubstring may misalign\n// after: use single-token names\nvar alice = new AssistantAgent(name: \"alice\", ...);\nvar bob = new AssistantAgent(name: \"bob\", ...);","handlingStrategy":"try-catch","validationCode":"// Sanity-check candidate names are single tokens the LLM can echo exactly\nif (candidates.Any(c => c.Name!.Contains(' ') || c.Name!.Length < 2))\n    throw new InvalidOperationException(\"Rename agents to single-token names before role-play orchestration\");","typeGuard":null,"tryCatchPattern":"for (int attempt = 0; attempt < 3; attempt++)\n{\n    try { return await orchestrator.GetNextSpeakerAsync(ctx, ct); }\n    catch (ArgumentException e) when (e.Message.Contains(\"not in the candidates list\") && attempt < 2)\n    { /* temperature-0 retry; LLM format drift is often transient */ }\n}","preventionTips":["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"],"tags":["autogen","group-chat","orchestrator","prompt-format"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}