{"record":{"id":"a1ae70730457c117","repo":"microsoft/semantic-kernel","slug":"subclasses-should-implement-this-method","errorCode":null,"errorMessage":"Subclasses should implement this method","messagePattern":"Subclasses should implement this method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/group_chat/agent_chat.py","lineNumber":55,"sourceCode":"    def is_active(self) -> bool:\n        \"\"\"Indicates whether the agent is currently active.\"\"\"\n        return self._is_active\n\n    def set_activity_or_throw(self):\n        \"\"\"Set the activity signal or throw an exception if another agent is active.\"\"\"\n        with self._lock:\n            if self._is_active:\n                raise Exception(\"Unable to proceed while another agent is active.\")\n            self._is_active = True\n\n    def clear_activity_signal(self):\n        \"\"\"Clear the activity signal.\"\"\"\n        with self._lock:\n            self._is_active = False\n\n    def invoke(self, agent: Agent | None = None, is_joining: bool = True) -> AsyncIterable[ChatMessageContent]:\n        \"\"\"Invoke the agent asynchronously.\"\"\"\n        raise NotImplementedError(\"Subclasses should implement this method\")\n\n    async def get_messages_in_descending_order(self) -> AsyncIterable[ChatMessageContent]:\n        \"\"\"Get messages in descending order asynchronously.\"\"\"\n        for index in range(len(self.history.messages) - 1, -1, -1):\n            yield self.history.messages[index]\n            await asyncio.sleep(0)  # Yield control to the event loop\n\n    async def get_chat_messages(self, agent: \"Agent | None\" = None) -> AsyncIterable[ChatMessageContent]:\n        \"\"\"Get chat messages asynchronously.\"\"\"\n        self.set_activity_or_throw()\n\n        logger.info(\"Getting chat messages\")\n\n        messages: AsyncIterable[ChatMessageContent] | None = None\n        try:\n            if agent is None:\n                messages = self.get_messages_in_descending_order()\n            else:","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/group_chat/agent_chat.py#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nchat = AgentChat()\nasync for msg in chat.invoke(agent):  # raises NotImplementedError\n    ...\n\n# after\nchat = AgentGroupChat(agents=[agent])\nasync for msg in chat.invoke(agent):\n    ...","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from semantic_kernel.agents.group_chat.agent_group_chat import AgentGroupChat\nfrom semantic_kernel.agents.group_chat.agent_chat import AgentChat\n\ndef is_concrete_chat(chat) -> bool:\n    return isinstance(chat, AgentGroupChat) and type(chat) is not AgentChat","tryCatchPattern":null,"preventionTips":["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."],"tags":["not-implemented","base-class","group-chat"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}