microsoft/semantic-kernel · error · NotImplementedError

The _inner_get_chat_message_contents method is not implement

Error message

The _inner_get_chat_message_contents method is not implemented.

What it means

Raised by the base ChatCompletionClientBase._inner_get_chat_message_contents stub. It is the default implementation meant to be overridden by each concrete chat completion connector; calling it directly means the subclass never provided a non-streaming chat handler.

Source

Thrown at python/semantic_kernel/connectors/ai/chat_completion_client_base.py:58

    instruction_role: str = Field(default_factory=lambda: "system", description="The role for instructions.")

    # region Internal methods to be implemented by the derived classes

    async def _inner_get_chat_message_contents(
        self,
        chat_history: "ChatHistory",
        settings: "PromptExecutionSettings",
    ) -> list["ChatMessageContent"]:
        """Send a chat request to the AI service.

        Args:
            chat_history (ChatHistory): The chat history to send.
            settings (PromptExecutionSettings): The settings for the request.

        Returns:
            chat_message_contents (list[ChatMessageContent]): The chat message contents representing the response(s).
        """
        raise NotImplementedError("The _inner_get_chat_message_contents method is not implemented.")

    async def _inner_get_streaming_chat_message_contents(
        self,
        chat_history: "ChatHistory",
        settings: "PromptExecutionSettings",
        function_invoke_attempt: int = 0,
    ) -> AsyncGenerator[list["StreamingChatMessageContent"], Any]:
        """Send a streaming chat request to the AI service.

        Args:
            chat_history: The chat history to send.
            settings: The settings for the request.
            function_invoke_attempt: The current attempt count for automatically invoking functions.

        Yields:
            streaming_chat_message_contents: The streaming chat message contents.
        """
        raise NotImplementedError("The _inner_get_streaming_chat_message_contents method is not implemented.")

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Implement 'async def _inner_get_chat_message_contents(self, chat_history, settings) -> list[ChatMessageContent]' in your service subclass.
  2. If you are calling a real provider, use the shipped connector class (e.g. AzureChatCompletion, OpenAIChatCompletion) rather than the abstract base.
  3. If your service is streaming-only, call get_streaming_chat_message_contents instead.

Example fix

# before
class MyService(ChatCompletionClientBase): ...
await my_service.get_chat_message_contents(history, settings)
# after
class MyService(ChatCompletionClientBase):
    async def _inner_get_chat_message_contents(self, chat_history, settings):
        return [ChatMessageContent(role=AuthorRole.ASSISTANT, items=[TextContent(text="hi")])]
Defensive patterns

Strategy: type-guard

Validate before calling

def service_implements_non_streaming(service) -> bool:
    import inspect
    from semantic_kernel.connectors.ai.chat_completion_client_base import ChatCompletionClientBase
    method = getattr(service, "_inner_get_chat_message_contents", None)
    base_method = ChatCompletionClientBase._inner_get_chat_message_contents
    return method is not None and method.__func__ is not base_method

Type guard

import inspect
from semantic_kernel.connectors.ai.chat_completion_client_base import ChatCompletionClientBase

def overrides_non_streaming_chat(cls: type) -> bool:
    m = cls.__dict__.get("_inner_get_chat_message_contents")
    return callable(m)

Try / catch

try:
    completions = await service.get_chat_message_contents(history, settings)
except NotImplementedError as e:
    if "_inner_get_chat_message_contents" in str(e):
        raise NotImplementedError("Service subclass must implement _inner_get_chat_message_contents") from e
    raise

Prevention

When it happens

Trigger: Instantiating a chat completion service that subclasses ChatCompletionClientBase but does not override _inner_get_chat_message_contents, then calling get_chat_message_contents/get_chat_message_content. Also fires in tests using a raw base instance.

Common situations: A custom connector class that forgot to implement the non-streaming method; a service that only implements streaming but the caller used the non-streaming API; a mock/stub subclass missing the override.

Related errors


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