microsoft/semantic-kernel · error · ValueError
Unsupported service: {service}. Supported services are: {',
Error message
Unsupported service: {service}. Supported services are: {', '.join([s.value for s in Services])} What it means
Raised by document_generator's CustomAgentBase.get_service() when the supplied service does not match a supported Services enum member. The method uses match/case over Services.AZURE_OPENAI and Services.OPENAI only; any other value (including a future enum member not yet wired up) falls to the default arm and raises ValueError listing the supported services.
Source
Thrown at python/samples/demos/document_generator/agents/custom_agent_base.py:75
Returns:
ChatCompletionClientBase: The AI service instance.
"""
match service:
case Services.AZURE_OPENAI:
from azure.identity import AzureCliCredential
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
return AzureChatCompletion(instruction_role=instruction_role, credential=AzureCliCredential())
case Services.OPENAI:
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
return OpenAIChatCompletion(instruction_role=instruction_role)
case _:
raise ValueError(
f"Unsupported service: {service}. Supported services are: {', '.join([s.value for s in Services])}"
)
@override
async def invoke(
self,
*,
messages: str | ChatMessageContent | list[str | ChatMessageContent] | None = None,
thread: "AgentThread | None" = None,
on_intermediate_message: Callable[[ChatMessageContent], Awaitable[None]] | None = None,
arguments: KernelArguments | None = None,
kernel: "Kernel | None" = None,
additional_user_message: str | None = None,
**kwargs: Any,
) -> AsyncIterable["AgentResponseItem[ChatMessageContent]"]:
normalized_messages = self._normalize_messages(messages)
if additional_user_message:View on GitHub (pinned to c028a0c7dc)
Solutions
- Use one of the supported Services members: Services.AZURE_OPENAI or Services.OPENAI when constructing the agent.
- If you genuinely need a new service, add a case Services.<YOUR_SERVICE> branch returning a ChatCompletion base before the default arm.
- Validate the service argument at the call site against the supported set before passing it in.
- Check for typos / ensure you imported Services from the correct module.
Example fix
// before agent = MyAgent(service='azure') # string, not enum // after from .custom_agent_base import Services agent = MyAgent(service=Services.AZURE_OPENAI)
Defensive patterns
Strategy: validation
Validate before calling
from .custom_agent_base import Services, CustomAgentBase
SUPPORTED = {Services.AZURE_OPENAI, Services.OPENAI}
if service not in SUPPORTED:
raise ValueError(f'service must be one of {[s.value for s in SUPPORTED]}')
agent = MyAgent(service=service) Type guard
from enum import Enum
from .custom_agent_base import Services
def is_supported_service(s) -> bool:
return isinstance(s, Services) and s in {Services.AZURE_OPENAI, Services.OPENAI} Prevention
- Centralize the supported-set check in a factory function.
- When extending the Services enum, add a failing test that requires a new case branch.
- Never pass strings; always pass the enum member.
When it happens
Trigger: Instantiating a custom agent subclass with service=Services.<UNSUPPORTED>, or passing a service value not in {AZURE_OPENAI, OPENAI}; adding a new enum member to Services without adding a corresponding case branch.
Common situations: Extending the Services enum with a new backend (e.g. OLLAMA, ANTHROPIC) but forgetting to add the case; passing a string instead of the enum; downgrading/upgrade of semantic-kernel where enum members change.
Related errors
- Failed to create Azure OpenAI settings: {exc}
- Please provide either an api_key, ad_token, ad_token_provide
- Please provide an Azure OpenAI endpoint
- Please provide an Azure OpenAI Responses deployment name
- AZURE_OPENAI_ENDPOINT is not set.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/6be444c3dd402a2e.
Report an issue: GitHub.