{"record":{"id":"ad7bcef7ab771acf","repo":"microsoft/semantic-kernel","slug":"expected-azureaiagentsettings-got-type-settings","errorCode":null,"errorMessage":"Expected AzureAIAgentSettings, got {type(settings).__name__}","messagePattern":"Expected AzureAIAgentSettings, got (.+?)","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":598,"sourceCode":"    def resolve_placeholders(\n        cls: type[_T],\n        yaml_str: str,\n        settings: \"KernelBaseSettings | None\" = None,\n        extras: dict[str, Any] | None = None,\n    ) -> str:\n        \"\"\"Substitute ${AzureAI:Key} placeholders with fields from AzureAIAgentSettings 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 = AzureAIAgentSettings()\n\n        if not isinstance(settings, AzureAIAgentSettings):\n            raise AgentInitializationException(f\"Expected AzureAIAgentSettings, got {type(settings).__name__}\")\n\n        field_mapping.update({\n            \"ChatModelId\": getattr(settings, \"model_deployment_name\", None),\n            \"Endpoint\": getattr(settings, \"endpoint\", None),\n            \"AgentId\": getattr(settings, \"agent_id\", None),\n            \"BingConnectionId\": getattr(settings, \"bing_connection_id\", None),\n            \"AzureAISearchConnectionId\": getattr(settings, \"azure_ai_search_connection_id\", None),\n            \"AzureAISearchIndexName\": getattr(settings, \"azure_ai_search_index_name\", 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, AzureAI:AzureAISearchConnectionId\n            section, _, key = full_key.partition(\":\")\n            if section != \"AzureAI\":","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L580-L616","documentation":"Raised by AzureAIAgent.resolve_placeholders when the 'settings' argument is not None and not an instance of AzureAIAgentSettings. The method reads specific fields off the settings object, so a foreign settings type is rejected. Surfaced as AgentInitializationException. Note: None is allowed (it constructs a default), only wrong types are rejected.","triggerScenarios":"Passing an OpenAIAgentSettings, KernelBaseSettings subclass, or a plain dict as the settings argument to resolve_placeholders; a custom settings class that is not AzureAIAgentSettings; mixing settings objects across connector types.","commonSituations":"Reusing a settings instance built for a different connector; a framework/hook that injects its own settings object into the placeholder resolver; refactoring that changed the expected settings class without updating callers.","solutions":["Pass an AzureAIAgentSettings instance (or None to use defaults built from env vars).","If you have values in another settings object, construct AzureAIAgentSettings from them before passing.","Double-check imports to ensure you are passing the Azure-specific settings class."],"exampleFix":"// before\nresolve_placeholders(yaml, settings=OpenAIAgentSettings())  // wrong type\n// after\nresolve_placeholders(yaml, settings=AzureAIAgentSettings())  // or settings=None","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.agents import AzureAIAgentSettings\ndef ensure_azure_settings(settings):\n    if settings is None:\n        return AzureAIAgentSettings()\n    if not isinstance(settings, AzureAIAgentSettings):\n        raise TypeError(f'Expected AzureAIAgentSettings, got {type(settings).__name__}')\n    return settings","typeGuard":"def is_azure_settings(settings) -> bool:\n    return settings is None or isinstance(settings, AzureAIAgentSettings)","tryCatchPattern":"try:\n    AzureAIAgent.resolve_placeholders(yaml, settings=settings)\nexcept AgentInitializationException as e:\n    if 'Expected AzureAIAgentSettings' in str(e):\n        log.error('Pass AzureAIAgentSettings or None, not another settings type')\n    raise","preventionTips":["Pass None to use default AzureAIAgentSettings rather than a foreign settings object.","Keep settings objects per-connector; do not reuse OpenAI settings for Azure.","Add a type check in any wrapper that forwards settings into resolve_placeholders."],"tags":["azure-ai","declarative-spec","settings","type-mismatch","agent-initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}