microsoft/autogen · error · NotImplementedError
Subclasses must implement _from_config
Error message
Subclasses must implement _from_config
What it means
The base implementation of _from_config raises NotImplementedError('Subclasses must implement _from_config') for any subclass that was instantiated but did not override the abstract classmethod. It fires when a subclass somehow bypasses ABC enforcement (e.g. via the module's _allow_private_constructor ContextVar path) or a subclass was left incomplete.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py:660
if not vector_fields or len(vector_fields) == 0:
raise ValueError("vector_fields must contain at least one field name for hybrid search")
if not search_fields or len(search_fields) == 0:
raise ValueError("search_fields must contain at least one field name for hybrid search")
@classmethod
@abstractmethod
def _from_config(cls, config: AzureAISearchConfig) -> "BaseAzureAISearchTool":
"""Create a tool instance from a configuration object.
This is an abstract method that must be implemented by subclasses.
"""
if cls is BaseAzureAISearchTool:
raise NotImplementedError(
"BaseAzureAISearchTool is an abstract base class and cannot be instantiated directly. "
"Use a concrete implementation like AzureAISearchTool."
)
raise NotImplementedError("Subclasses must implement _from_config")
@abstractmethod
async def _get_embedding(self, query: str) -> List[float]:
"""Generate embedding vector for the query text."""
raise NotImplementedError("Subclasses must implement _get_embedding")
_allow_private_constructor = ContextVar("_allow_private_constructor", default=False)
class AzureAISearchTool(EmbeddingProviderMixin, BaseAzureAISearchTool):
"""Azure AI Search tool for querying Azure search indexes.
This tool provides a simplified interface for querying Azure AI Search indexes using
various search methods. It's recommended to use the factory methods to create
instances tailored for specific search types:
1. **Full-Text Search**: For traditional keyword-based searches, Lucene queries, orView on GitHub (pinned to 027ecf0a37)
Solutions
- Implement _from_config(cls, config: AzureAISearchConfig) -> Self in your subclass, constructing your instance from the config object.
- Or inherit from the concrete AzureAISearchTool / EmbeddingProviderMixin stack instead of the raw base.
- Run a quick isinstance/abstract check in tests: assert your class can be constructed normally (ABC will flag missing members at instantiation).
Example fix
# before
class MyTool(BaseAzureAISearchTool):
...
# after
class MyTool(BaseAzureAISearchTool):
@classmethod
def _from_config(cls, config: AzureAISearchConfig) -> 'MyTool':
return cls(name=config.name, endpoint=config.endpoint, index_name=config.index_name, credential=config.credential) Defensive patterns
Strategy: type-guard
Validate before calling
def subclass_is_complete(cls) -> bool:
from autogen_ext.tools.azure._ai_search import BaseAzureAISearchTool
return issubclass(cls, BaseAzureAISearchTool) and '_from_config' in cls.__dict__ Type guard
def implements_from_config(cls) -> bool:
return any('_from_config' in vars(c) for c in cls.__mro__ if c is not object) Prevention
- Satisfy every abstractmember of BaseAzureAISearchTool before writing tests; instantiation of a complete subclass fails fast via ABC.
- Add an abstract-class completeness test: `test_subclass_implements_all_abstract_methods()`.
- Prefer composing with AzureAISearchTool / EmbeddingProviderMixin over subclassing the raw base.
When it happens
Trigger: Defining a class inheriting BaseAzureAISearchTool without implementing _from_config, then constructing it through internal/private paths that skip abstractmethod checks; calling _from_config on such an incomplete subclass.
Common situations: Mid-way through writing a custom tool subclass and testing before all abstract members exist; copy-pasting a subclass template that omits _from_config.
Related errors
- BaseAzureAISearchTool is an abstract base class and cannot b
- Subclasses must implement _get_embedding
- Index '{self.search_config.index_name}' not found.
- Error from Azure AI Search: {error_msg}
- Invalid configuration: {str(e)}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/a87982d60e040e1c.
Report an issue: GitHub.