{"record":{"id":"19765ce2ac1e3979","repo":"microsoft/semantic-kernel","slug":"this-method-is-not-implemented-for-copilotstudioag","errorCode":null,"errorMessage":"This method is not implemented for CopilotStudioAgent. Messages and responses are automatically handled by the Copilot Agent.","messagePattern":"This method is not implemented for CopilotStudioAgent\\. Messages and responses are automatically handled by the Copilot Agent\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py","lineNumber":252,"sourceCode":"    @override\n    async def _create(self) -> str:\n        # Creation is deferred to CopilotStudioAgent._ensure_conversation.\n        if self._is_deleted:\n            raise AgentThreadOperationException(\"Cannot create a thread that has been deleted.\")\n        return \"\"\n\n    @override\n    async def _delete(self) -> None:\n        if self._is_deleted:\n            return\n        if self.conversation_id is None:\n            raise AgentThreadOperationException(\"Cannot delete the thread, since it has not been created.\")\n        self._conversation_id = None\n        self._is_deleted = True\n\n    @override\n    async def _on_new_message(self, new_message: ChatMessageContent) -> None:\n        raise NotImplementedError(\n            \"This method is not implemented for CopilotStudioAgent. \"\n            \"Messages and responses are automatically handled by the Copilot Agent.\"\n        )\n\n\n@experimental\nclass CopilotStudioAgent(Agent):\n    \"\"\"Semantic Kernel abstraction over a Copilot Studio Agent.\"\"\"\n\n    client: CopilotClient\n    channel_type: ClassVar[type[AgentChannel] | None] = None\n\n    def __init__(\n        self,\n        *,\n        client: CopilotClient | None = None,\n        arguments: KernelArguments | None = None,\n        description: str | None = None,","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py#L234-L270","documentation":"Raised by CopilotStudioAgentThread._on_new_message(), which is overridden to always raise NotImplementedError. CopilotStudioAgent does not use the standard AgentThread message-notification path — messages and responses are handled entirely by the CopilotClient (ask_question / start_conversation). The agent's own _notify_thread_of_new_message is a no-op, so this method should never be reached in normal flow; it exists as a defensive guard.","triggerScenarios":"Directly calling thread._on_new_message(msg) on a CopilotStudioAgentThread, or a code path in a subclass/framework that bypasses CopilotStudioAgent._notify_thread_of_new_message and invokes the base AgentThread notification logic.","commonSituations":"Custom subclassing of CopilotStudioAgentThread or Agent that re-enables the standard notification path; calling private methods directly in tests; integration with a framework that expects all AgentThread subclasses to support _on_new_message.","solutions":["Do not call _on_new_message on CopilotStudioAgentThread — use agent.invoke()/get_response() instead.","If subclassing, override _notify_thread_of_new_message to remain a no-op and route messages through the agent's invoke methods.","If you need per-message hooks, use the on_intermediate_message callback parameter of invoke/invoke_stream."],"exampleFix":"# before — calling the unsupported private method\nawait thread._on_new_message(msg)  # raises NotImplementedError\n\n# after — use the agent's invoke with a callback\nasync def on_msg(msg):\n    print(msg.content)\nasync for resp in agent.invoke(\"hello\", thread=thread, on_intermediate_message=on_msg):\n    ...","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await thread._on_new_message(msg)\nexcept NotImplementedError:\n    # Use the agent's invoke methods instead\n    await agent.invoke(msg.content, thread=thread)","preventionTips":["Never call _on_new_message on a CopilotStudioAgentThread.","Use the on_intermediate_message callback for message hooks.","Keep CopilotStudioAgent._notify_thread_of_new_message as a no-op when subclassing."],"tags":["not-implemented","thread","copilot-studio"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}