{"record":{"id":"6be444c3dd402a2e","repo":"microsoft/semantic-kernel","slug":"unsupported-service-service-supported-services","errorCode":null,"errorMessage":"Unsupported service: {service}. Supported services are: {', '.join([s.value for s in Services])}","messagePattern":"Unsupported service: (.+?)\\. Supported services are: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/samples/demos/document_generator/agents/custom_agent_base.py","lineNumber":75,"sourceCode":"\n        Returns:\n            ChatCompletionClientBase: The AI service instance.\n\n        \"\"\"\n\n        match service:\n            case Services.AZURE_OPENAI:\n                from azure.identity import AzureCliCredential\n\n                from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion\n\n                return AzureChatCompletion(instruction_role=instruction_role, credential=AzureCliCredential())\n            case Services.OPENAI:\n                from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion\n\n                return OpenAIChatCompletion(instruction_role=instruction_role)\n            case _:\n                raise ValueError(\n                    f\"Unsupported service: {service}. Supported services are: {', '.join([s.value for s in Services])}\"\n                )\n\n    @override\n    async def invoke(\n        self,\n        *,\n        messages: str | ChatMessageContent | list[str | ChatMessageContent] | None = None,\n        thread: \"AgentThread | None\" = None,\n        on_intermediate_message: Callable[[ChatMessageContent], Awaitable[None]] | None = None,\n        arguments: KernelArguments | None = None,\n        kernel: \"Kernel | None\" = None,\n        additional_user_message: str | None = None,\n        **kwargs: Any,\n    ) -> AsyncIterable[\"AgentResponseItem[ChatMessageContent]\"]:\n        normalized_messages = self._normalize_messages(messages)\n\n        if additional_user_message:","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/samples/demos/document_generator/agents/custom_agent_base.py#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nagent = MyAgent(service='azure')  # string, not enum\n\n// after\nfrom .custom_agent_base import Services\nagent = MyAgent(service=Services.AZURE_OPENAI)","handlingStrategy":"validation","validationCode":"from .custom_agent_base import Services, CustomAgentBase\nSUPPORTED = {Services.AZURE_OPENAI, Services.OPENAI}\nif service not in SUPPORTED:\n    raise ValueError(f'service must be one of {[s.value for s in SUPPORTED]}')\nagent = MyAgent(service=service)","typeGuard":"from enum import Enum\nfrom .custom_agent_base import Services\n\ndef is_supported_service(s) -> bool:\n    return isinstance(s, Services) and s in {Services.AZURE_OPENAI, Services.OPENAI}","tryCatchPattern":null,"preventionTips":["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."],"tags":["configuration","enum","azure-openai","agents","input-validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}