microsoft/semantic-kernel · error · NotImplementedError

This method is not implemented for CopilotStudioAgent. Messa

Error message

This method is not implemented for CopilotStudioAgent. Messages and responses are automatically handled by the Copilot Agent.

What it means

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.

Source

Thrown at python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py:252

    @override
    async def _create(self) -> str:
        # Creation is deferred to CopilotStudioAgent._ensure_conversation.
        if self._is_deleted:
            raise AgentThreadOperationException("Cannot create a thread that has been deleted.")
        return ""

    @override
    async def _delete(self) -> None:
        if self._is_deleted:
            return
        if self.conversation_id is None:
            raise AgentThreadOperationException("Cannot delete the thread, since it has not been created.")
        self._conversation_id = None
        self._is_deleted = True

    @override
    async def _on_new_message(self, new_message: ChatMessageContent) -> None:
        raise NotImplementedError(
            "This method is not implemented for CopilotStudioAgent. "
            "Messages and responses are automatically handled by the Copilot Agent."
        )


@experimental
class CopilotStudioAgent(Agent):
    """Semantic Kernel abstraction over a Copilot Studio Agent."""

    client: CopilotClient
    channel_type: ClassVar[type[AgentChannel] | None] = None

    def __init__(
        self,
        *,
        client: CopilotClient | None = None,
        arguments: KernelArguments | None = None,
        description: str | None = None,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Do not call _on_new_message on CopilotStudioAgentThread — use agent.invoke()/get_response() instead.
  2. If subclassing, override _notify_thread_of_new_message to remain a no-op and route messages through the agent's invoke methods.
  3. If you need per-message hooks, use the on_intermediate_message callback parameter of invoke/invoke_stream.

Example fix

# before — calling the unsupported private method
await thread._on_new_message(msg)  # raises NotImplementedError

# after — use the agent's invoke with a callback
async def on_msg(msg):
    print(msg.content)
async for resp in agent.invoke("hello", thread=thread, on_intermediate_message=on_msg):
    ...
Defensive patterns

Strategy: try-catch

Try / catch

try:
    await thread._on_new_message(msg)
except NotImplementedError:
    # Use the agent's invoke methods instead
    await agent.invoke(msg.content, thread=thread)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/19765ce2ac1e3979. Report an issue: GitHub.