microsoft/semantic-kernel · error · RuntimeError
Unknown participant selected: {response.content}.
Error message
Unknown participant selected: {response.content}. What it means
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.
Source
Thrown at python/samples/getting_started_with_agents/multi_agent_orchestration/step3b_group_chat_with_chat_completion_manager.py:265
)
response = await self.service.get_chat_message_content(
chat_history,
settings=PromptExecutionSettings(response_format=StringResult),
)
participant_name_with_reason = StringResult.model_validate_json(response.content)
print("*********************")
print(
f"Next participant: {participant_name_with_reason.result}\nReason: {participant_name_with_reason.reason}."
)
print("*********************")
if participant_name_with_reason.result in participant_descriptions:
return participant_name_with_reason
raise RuntimeError(f"Unknown participant selected: {response.content}.")
@override
async def filter_results(
self,
chat_history: ChatHistory,
) -> MessageResult:
"""Provide concrete implementation for filtering the results of the discussion.
The manager will filter the results of the conversation after the conversation is terminated.
"""
if not chat_history.messages:
raise RuntimeError("No messages in the chat history.")
chat_history.messages.insert(
0,
ChatMessageContent(
role=AuthorRole.SYSTEM,
content=await self._render_prompt(View on GitHub (pinned to c028a0c7dc)
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.
Example fix
# before
if participant_name_with_reason.result in participant_descriptions:
return participant_name_with_reason.result
# after (normalize + fuzzy fallback)
name = participant_name_with_reason.result.strip().strip('"\'')
match = next((k for k in participant_descriptions if k.lower() == name.lower()), None)
if match:
return match
raise RuntimeError(f"Unknown participant selected: {response.content}.") Defensive patterns
Strategy: validation
Validate before calling
name = participant_name_with_reason.result.strip().strip('"\'')
known = set(participant_descriptions)
assert name in known or name.lower() in {k.lower() for k in known}, \
f'Unknown participant: {name}; known: {sorted(known)}' Type guard
def is_known_participant(name: str, descriptions: dict) -> bool:
n = name.strip().strip('"\'').lower()
return n in {k.lower() for k in descriptions} Try / catch
try:
return await manager.select_next_participant(chat_history)
except RuntimeError as e:
if 'Unknown participant' in str(e):
# normalize/reprompt the manager with stricter instructions
...
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No messages in the chat history.
- Failed to parse response: {responseText}
- {nameof(A2AAgent)} is not for use with {nameof(AgentChat)}.
- Missing agent description: {agent.Name ?? agent.Id}
- Entry agent is not defined.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/e4e2a05246312ea7.
Report an issue: GitHub.