{"record":{"id":"f214f7572aa622c6","repo":"microsoft/autogen","slug":"baseazureaisearchtool-is-an-abstract-base-class-an","errorCode":null,"errorMessage":"BaseAzureAISearchTool is an abstract base class and cannot be instantiated directly. Use a concrete implementation like AzureAISearchTool.","messagePattern":"BaseAzureAISearchTool is an abstract base class and cannot be instantiated directly\\. Use a concrete implementation like AzureAISearchTool\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":656,"sourceCode":"        elif search_type == \"hybrid\":\n            vector_fields = config_dict.get(\"vector_fields\")\n            search_fields = config_dict.get(\"search_fields\")\n\n            if not vector_fields or len(vector_fields) == 0:\n                raise ValueError(\"vector_fields must contain at least one field name for hybrid search\")\n\n            if not search_fields or len(search_fields) == 0:\n                raise ValueError(\"search_fields must contain at least one field name for hybrid search\")\n\n    @classmethod\n    @abstractmethod\n    def _from_config(cls, config: AzureAISearchConfig) -> \"BaseAzureAISearchTool\":\n        \"\"\"Create a tool instance from a configuration object.\n\n        This is an abstract method that must be implemented by subclasses.\n        \"\"\"\n        if cls is BaseAzureAISearchTool:\n            raise NotImplementedError(\n                \"BaseAzureAISearchTool is an abstract base class and cannot be instantiated directly. \"\n                \"Use a concrete implementation like AzureAISearchTool.\"\n            )\n        raise NotImplementedError(\"Subclasses must implement _from_config\")\n\n    @abstractmethod\n    async def _get_embedding(self, query: str) -> List[float]:\n        \"\"\"Generate embedding vector for the query text.\"\"\"\n        raise NotImplementedError(\"Subclasses must implement _get_embedding\")\n\n\n_allow_private_constructor = ContextVar(\"_allow_private_constructor\", default=False)\n\n\nclass AzureAISearchTool(EmbeddingProviderMixin, BaseAzureAISearchTool):\n    \"\"\"Azure AI Search tool for querying Azure search indexes.\n\n    This tool provides a simplified interface for querying Azure AI Search indexes using","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L638-L674","documentation":"_from_config on BaseAzureAISearchTool is a guarded abstract classmethod. If invoked on the base class itself (cls is BaseAzureAISearchTool) it raises NotImplementedError telling you to use a concrete implementation such as AzureAISearchTool. This is a programmer-facing guard for custom subclasses and internal plumbing, not a runtime service error.","triggerScenarios":"Calling BaseAzureAISearchTool._from_config(config) directly, or writing a custom subclass whose _from_config implementation delegates to super()._from_config (which lands on the base implementation).","commonSituations":"Writing a custom search tool subclass and accidentally calling super()._from_config(config) inside it; generic factory code that receives the base class as a parameter instead of a concrete tool class.","solutions":["Call the concrete class instead: AzureAISearchTool._from_config(config) (or just use its public factory methods).","In custom subclasses, do not delegate _from_config to super(); construct the concrete instance directly.","If you never extend these classes, this error indicates you are reaching into private API — switch to the documented factory constructors."],"exampleFix":"# before\ntool = BaseAzureAISearchTool._from_config(cfg)\n# after\ntool = AzureAISearchTool._from_config(cfg)","handlingStrategy":"type-guard","validationCode":"from autogen_ext.tools.azure._ai_search import BaseAzureAISearchTool, AzureAISearchTool\n\ndef is_concrete_tool_cls(cls) -> bool:\n    return cls is not BaseAzureAISearchTool","typeGuard":"def can_from_config(cls) -> bool:\n    from autogen_ext.tools.azure._ai_search import BaseAzureAISearchTool\n    return cls is not BaseAzureAISearchTool and '_from_config' in cls.__dict__","tryCatchPattern":"try:\n    tool = cls._from_config(cfg)\nexcept NotImplementedError:\n    if cls is BaseAzureAISearchTool:\n        cls = AzureAISearchTool  # fall back to the concrete class\n        tool = cls._from_config(cfg)\n    else:\n        raise","preventionTips":["Never call private _from_config on the base class; use public factory methods.","In generic code, accept only concrete tool classes and assert that at the boundary.","In subclasses, do not delegate _from_config to super()."],"tags":["azure","azure-ai-search","abstract-class","subclassing","not-implemented"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}