microsoft/semantic-kernel · error · NotImplementedError

Unable to get channel keys. Channel type not configured.

Error message

Unable to get channel keys. Channel type not configured.

What it means

Agent.get_channel_keys() yields the channel type's class name, but only if the subclass set the channel_type ClassVar. The base Agent leaves channel_type = None, so calling get_channel_keys on a base/incompletely-subclassed agent raises NotImplementedError. Every concrete agent must declare its channel_type to participate in agent chats.

Source

Thrown at python/semantic_kernel/agents/agent.py:426

            kwargs: Additional keyword arguments.

        Yields:
            An agent response item.
        """
        pass

    # endregion

    # region Channel Management

    def get_channel_keys(self) -> Iterable[str]:
        """Get the channel keys.

        Returns:
            A list of channel keys.
        """
        if not self.channel_type:
            raise NotImplementedError("Unable to get channel keys. Channel type not configured.")
        yield self.channel_type.__name__

    async def create_channel(self) -> AgentChannel:
        """Create a channel.

        Returns:
            An instance of AgentChannel.
        """
        if not self.channel_type:
            raise NotImplementedError("Unable to create channel. Channel type not configured.")
        return self.channel_type()

    # endregion

    # region Instructions Management

    async def format_instructions(self, kernel: Kernel, arguments: KernelArguments | None = None) -> str | None:
        """Format the instructions.

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Use a concrete built-in agent (ChatCompletionAgent, OpenAIAssistantAgent, etc.) which already sets channel_type.
  2. In a custom Agent subclass, set channel_type to an appropriate AgentChannel subclass (ClassVar[type[AgentChannel]]).
  3. Do not instantiate the abstract Agent base directly.

Example fix

# before
class MyAgent(Agent):
    ...  # channel_type missing -> error
# after
from semantic_kernel.agents.channels.chat_history_channel import ChatHistoryChannel
class MyAgent(Agent):
    channel_type: ClassVar[type[AgentChannel]] = ChatHistoryChannel
Defensive patterns

Strategy: type-guard

Validate before calling

assert agent.channel_type is not None, \
    f'{type(agent).__name__} must set channel_type to participate in chats'

Type guard

from semantic_kernel.agents.channels.agent_channel import AgentChannel
def agent_has_channel(agent) -> bool:
    return getattr(type(agent), 'channel_type', None) is not None and issubclass(type(agent).channel_type, AgentChannel)

Prevention

When it happens

Trigger: Instantiating the abstract Agent base directly (or a subclass that forgot to set channel_type) and adding it to an AgentGroupChat / chat, which calls get_channel_keys.

Common situations: Writing a custom agent subclass and omitting channel_type; instantiating Agent itself; subclassing a chat agent but not assigning a channel type.

Related errors


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