microsoft/semantic-kernel · error · AgentChatException
No agents are available
Error message
No agents are available
What it means
Raised by AgentGroupChat.invoke() when no agent argument is supplied and self.agents is empty. The group-chat invoke loop needs at least one agent to select and invoke via the selection strategy. With zero agents there is nothing to iterate. It is an AgentChatException.
Solutions
- Pass agents to the AgentGroupChat constructor: AgentGroupChat(agents=[a1, a2]).
- Call chat.add_agent(agent) before invoking.
- Guard the invoke call: if not chat.agents: add agents first.
Example fix
# before
chat = AgentGroupChat()
async for msg in chat.invoke(): # raises
...
# after
chat = AgentGroupChat(agents=[agent1, agent2])
async for msg in chat.invoke():
... Defensive patterns
Strategy: validation
Validate before calling
if not chat.agents:
raise ValueError("Add at least one agent before invoking the group chat")
async for msg in chat.invoke():
... Type guard
def has_agents(chat) -> bool:
return len(chat.agents) > 0 Prevention
- Pass agents to the AgentGroupChat constructor or call add_agent before invoke.
- Guard invoke calls with a check on chat.agents.
- Validate dynamic agent lists are non-empty before constructing the group chat.
When it happens
Trigger: Constructing AgentGroupChat() with no agents (or an empty list) and then calling await chat.invoke() (no agent argument) expecting automatic multi-agent iteration.
Common situations: Agents added conditionally and the condition never met; agents list built dynamically and came back empty; forgetting to pass agents to the AgentGroupChat constructor or call add_agent before invoke.
Related errors
- All members must have a description.
- Channel Keys must not be empty. Unable to generate channel…
- Invalid message body type
- System messages cannot be added to the chat history.
- A complete then action is required for orchestration steps.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/245d742e133db1d4.
Report an issue: GitHub.
Appendix: source
Thrown at python/semantic_kernel/agents/group_chat/agent_group_chat.py:141
is_joining: Controls whether the agent joins the chat. Defaults to True.
Yields:
The chat message.
"""
if agent is not None:
if is_joining:
self.add_agent(agent)
async for message in super().invoke_agent(agent):
if message.role == AuthorRole.ASSISTANT:
task = self.termination_strategy.should_terminate(agent, self.history.messages)
self.is_complete = await task
yield message
return
if not self.agents:
raise AgentChatException("No agents are available")
if self.is_complete:
if not self.termination_strategy.automatic_reset:
raise AgentChatException("Chat is already complete")
self.is_complete = False
for _ in range(self.termination_strategy.maximum_iterations):
try:
selected_agent = await self.selection_strategy.next(self.agents, self.history.messages)
except Exception as ex:
logger.error(f"Failed to select agent: {ex}")
raise AgentChatException("Failed to select agent") from ex
async for message in super().invoke_agent(selected_agent):
if message.role == AuthorRole.ASSISTANT:
task = self.termination_strategy.should_terminate(selected_agent, self.history.messages)
self.is_complete = await taskView on GitHub (pinned to c028a0c7dc)