{"record":{"id":"86f2acaa29e2205c","repo":"microsoft/semantic-kernel","slug":"expected-azureopenaisettings-got-type-settings-86f2ac","errorCode":null,"errorMessage":"Expected AzureOpenAISettings, got {type(settings).__name__}","messagePattern":"Expected AzureOpenAISettings, got (.+?)","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/azure_responses_agent.py","lineNumber":259,"sourceCode":"    def resolve_placeholders(\n        cls: type[Self],\n        yaml_str: str,\n        settings: \"KernelBaseSettings | None\" = None,\n        extras: dict[str, Any] | None = None,\n    ) -> str:\n        \"\"\"Substitute ${AzureOpenAI:Key} placeholders with fields from AzureOpenAIAgentSettings and extras.\"\"\"\n        import re\n\n        pattern = re.compile(r\"\\$\\{([^}]+)\\}\")\n\n        # Build the mapping only if settings is provided and valid\n        field_mapping: dict[str, Any] = {}\n\n        if settings is None:\n            settings = AzureOpenAISettings()\n\n        if not isinstance(settings, AzureOpenAISettings):\n            raise AgentInitializationException(f\"Expected AzureOpenAISettings, got {type(settings).__name__}\")\n\n        field_mapping.update({\n            \"ChatModelId\": getattr(settings, \"responses_deployment_name\", None),\n            \"AgentId\": getattr(settings, \"agent_id\", None),\n            \"ApiKey\": getattr(settings, \"api_key\", None),\n            \"ApiVersion\": getattr(settings, \"api_version\", None),\n            \"BaseUrl\": getattr(settings, \"base_url\", None),\n            \"Endpoint\": getattr(settings, \"endpoint\", None),\n            \"TokenEndpoint\": getattr(settings, \"token_endpoint\", None),\n        })\n\n        if extras:\n            field_mapping.update(extras)\n\n        def replacer(match: re.Match[str]) -> str:\n            \"\"\"Replace the matched placeholder with the corresponding value from field_mapping.\"\"\"\n            full_key = match.group(1)  # for example, AzureOpenAI:ApiKey\n            section, _, key = full_key.partition(\":\")","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/azure_responses_agent.py#L241-L277","documentation":"Raised by AzureResponsesAgent.resolve_placeholders() when the settings argument is not None and is not an AzureOpenAISettings instance. The method reads responses_deployment_name, api_key, etc. directly off the object, so a wrong type would produce incorrect substitutions; it fails fast instead.","triggerScenarios":"Calling AzureResponsesAgent.resolve_placeholders(yaml_str, settings=<wrong type>) such as OpenAISettings, a dict, or another pydantic model. Passing None is allowed (defaults to AzureOpenAISettings()).","commonSituations":"Sharing a generic config object across agents; importing the wrong settings class; passing a dict of resolved values instead of an AzureOpenAISettings instance.","solutions":["Pass an AzureOpenAISettings instance, or None.","Build AzureOpenAISettings(...) from your shared config before calling resolve_placeholders.","Verify the import path resolves to AzureOpenAISettings (not OpenAISettings)."],"exampleFix":"# before\nAzureResponsesAgent.resolve_placeholders(yaml, settings=my_generic_config)\n# after\nAzureResponsesAgent.resolve_placeholders(yaml, settings=AzureOpenAISettings())  # or None","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from semantic_kernel.connectors.ai.open_ai.settings import AzureOpenAISettings\n\ndef is_azure_openai_settings(s) -> bool:\n    return isinstance(s, AzureOpenAISettings)\n\nif settings is not None and not is_azure_openai_settings(settings):\n    settings = AzureOpenAISettings()","tryCatchPattern":null,"preventionTips":["Pass None or an AzureOpenAISettings instance to resolve_placeholders.","Convert shared config to AzureOpenAISettings at the boundary.","Annotate the settings parameter with the concrete type for static checking."],"tags":["azure-openai","declarative-spec","semantic-kernel","agents","type-validation","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}