microsoft/semantic-kernel · error · NotImplementedError
Subclasses should implement this method
Error message
Subclasses should implement this method
What it means
Raised by AgentChat.invoke() — the base class intentionally raises NotImplementedError because AgentChat is an abstract base meant to be subclassed (AgentGroupChat provides the concrete implementation). The method signature exists for interface conformance but has no usable behavior on the base class.
Source
Thrown at python/semantic_kernel/agents/group_chat/agent_chat.py:55
def is_active(self) -> bool:
"""Indicates whether the agent is currently active."""
return self._is_active
def set_activity_or_throw(self):
"""Set the activity signal or throw an exception if another agent is active."""
with self._lock:
if self._is_active:
raise Exception("Unable to proceed while another agent is active.")
self._is_active = True
def clear_activity_signal(self):
"""Clear the activity signal."""
with self._lock:
self._is_active = False
def invoke(self, agent: Agent | None = None, is_joining: bool = True) -> AsyncIterable[ChatMessageContent]:
"""Invoke the agent asynchronously."""
raise NotImplementedError("Subclasses should implement this method")
async def get_messages_in_descending_order(self) -> AsyncIterable[ChatMessageContent]:
"""Get messages in descending order asynchronously."""
for index in range(len(self.history.messages) - 1, -1, -1):
yield self.history.messages[index]
await asyncio.sleep(0) # Yield control to the event loop
async def get_chat_messages(self, agent: "Agent | None" = None) -> AsyncIterable[ChatMessageContent]:
"""Get chat messages asynchronously."""
self.set_activity_or_throw()
logger.info("Getting chat messages")
messages: AsyncIterable[ChatMessageContent] | None = None
try:
if agent is None:
messages = self.get_messages_in_descending_order()
else:View on GitHub (pinned to c028a0c7dc)
Solutions
- Use AgentGroupChat (or another concrete subclass) instead of the base AgentChat.
- If you subclass AgentChat, override invoke() with a real implementation.
- Fix type annotations and factory code to always produce a concrete subclass instance.
Example fix
# before
chat = AgentChat()
async for msg in chat.invoke(agent): # raises NotImplementedError
...
# after
chat = AgentGroupChat(agents=[agent])
async for msg in chat.invoke(agent):
... Defensive patterns
Strategy: type-guard
Type guard
from semantic_kernel.agents.group_chat.agent_group_chat import AgentGroupChat
from semantic_kernel.agents.group_chat.agent_chat import AgentChat
def is_concrete_chat(chat) -> bool:
return isinstance(chat, AgentGroupChat) and type(chat) is not AgentChat Prevention
- Always instantiate AgentGroupChat or another concrete subclass, never the base AgentChat.
- In factory functions, ensure the return type is a concrete subclass.
- Review test fixtures to confirm they use concrete subclasses.
When it happens
Trigger: Instantiating AgentChat directly and calling .invoke() on it, rather than using a subclass like AgentGroupChat. This is unlikely in normal application code but can happen in tests, dynamic dispatch, or code that incorrectly types a variable as AgentChat.
Common situations: Test fixtures that construct AgentChat instead of AgentGroupChat; refactoring that changes a concrete subclass to the base class by accident; framework code that instantiates a class from a registry that accidentally registers the base.
Related errors
- Failed to parse response: {responseText}
- This method is not implemented in this test fixture.
- Streaming text contents not implemented.
- Streaming chat message contents not implemented.
- Refresh tokens not supported
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/a1ae70730457c117.
Report an issue: GitHub.