{"record":{"id":"e4e2a05246312ea7","repo":"microsoft/semantic-kernel","slug":"unknown-participant-selected-response-content","errorCode":null,"errorMessage":"Unknown participant selected: {response.content}.","messagePattern":"Unknown participant selected: (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/samples/getting_started_with_agents/multi_agent_orchestration/step3b_group_chat_with_chat_completion_manager.py","lineNumber":265,"sourceCode":"        )\n\n        response = await self.service.get_chat_message_content(\n            chat_history,\n            settings=PromptExecutionSettings(response_format=StringResult),\n        )\n\n        participant_name_with_reason = StringResult.model_validate_json(response.content)\n\n        print(\"*********************\")\n        print(\n            f\"Next participant: {participant_name_with_reason.result}\\nReason: {participant_name_with_reason.reason}.\"\n        )\n        print(\"*********************\")\n\n        if participant_name_with_reason.result in participant_descriptions:\n            return participant_name_with_reason\n\n        raise RuntimeError(f\"Unknown participant selected: {response.content}.\")\n\n    @override\n    async def filter_results(\n        self,\n        chat_history: ChatHistory,\n    ) -> MessageResult:\n        \"\"\"Provide concrete implementation for filtering the results of the discussion.\n\n        The manager will filter the results of the conversation after the conversation is terminated.\n        \"\"\"\n        if not chat_history.messages:\n            raise RuntimeError(\"No messages in the chat history.\")\n\n        chat_history.messages.insert(\n            0,\n            ChatMessageContent(\n                role=AuthorRole.SYSTEM,\n                content=await self._render_prompt(","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/samples/getting_started_with_agents/multi_agent_orchestration/step3b_group_chat_with_chat_completion_manager.py#L247-L283","documentation":"Thrown by the custom group-chat manager after the manager LLM picks the next participant. The model's response (parsed into StringResult) yielded a name that is not a key in participant_descriptions, so the manager refuses to hand off to an unknown agent. This is a guard against the LLM hallucinating an agent name.","triggerScenarios":"The manager completion returns a participant name with different casing/spelling than registered; the model invents a name not in the group; the structured StringResult parsing captured extra text in result.","commonSituations":"Model returns the agent description instead of its name, includes surrounding quotes/whitespace, or picks a role rather than the configured name; prompt describing participants is ambiguous; temperature too high causing creative names.","solutions":["Ensure participant names in the manager prompt exactly match the keys of participant_descriptions (case-sensitive).","Tighten the manager prompt to constrain output to the exact registered names, and lower temperature.","Normalize the model output (strip quotes/whitespace, case-fold) before the membership check, or add fuzzy matching against known names.","Inspect response.content printed in the error to see what the model actually returned and adjust the schema/prompt accordingly."],"exampleFix":"# before\nif participant_name_with_reason.result in participant_descriptions:\n    return participant_name_with_reason.result\n# after (normalize + fuzzy fallback)\nname = participant_name_with_reason.result.strip().strip('\"\\'')\nmatch = next((k for k in participant_descriptions if k.lower() == name.lower()), None)\nif match:\n    return match\nraise RuntimeError(f\"Unknown participant selected: {response.content}.\")","handlingStrategy":"validation","validationCode":"name = participant_name_with_reason.result.strip().strip('\"\\'')\nknown = set(participant_descriptions)\nassert name in known or name.lower() in {k.lower() for k in known}, \\\n    f'Unknown participant: {name}; known: {sorted(known)}'","typeGuard":"def is_known_participant(name: str, descriptions: dict) -> bool:\n    n = name.strip().strip('\"\\'').lower()\n    return n in {k.lower() for k in descriptions}","tryCatchPattern":"try:\n    return await manager.select_next_participant(chat_history)\nexcept RuntimeError as e:\n    if 'Unknown participant' in str(e):\n        # normalize/reprompt the manager with stricter instructions\n        ...\n    raise","preventionTips":["List participant names verbatim in the manager prompt.","Lower the manager model temperature.","Normalize model output (strip quotes/whitespace) before matching.","Log response.content to diagnose the exact unexpected name."],"tags":["agents","orchestration","group-chat","llm-output","multi-agent"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}