microsoft/autogen · error · TypeError

Invalid component class

Error message

Invalid component class

What it means

Error "Invalid component class" thrown in microsoft/autogen.

Solutions

  1. Ensure the class inherits the expected component base and implements required methods

Example fix

Subclass the correct Component base and define component_type

When it happens

Trigger: Thrown at python/packages/autogen-core/src/autogen_core/_component_config.py:276 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/3f62ce2b0f8f0f68. Report an issue: GitHub.

Appendix: source

Thrown at python/packages/autogen-core/src/autogen_core/_component_config.py:276

        module_name = module_path.rsplit(".", maxsplit=1)[-1]
        is_test_module = module_name.startswith("test_") or module_path.startswith("test_")
        if not is_test_module and not any(
            module_path.startswith(ns) or module_path == ns.rstrip(".") for ns in trusted
        ):
            raise ValueError(
                f"Provider module '{module_path}' is not in a trusted namespace. "
                f"Allowed namespaces by default: autogen_core, autogen_agentchat, autogen_ext, "
                f"autogen_studio, autogenstudio. "
                f"To allow additional namespaces, set the AUTOGEN_ALLOWED_PROVIDER_NAMESPACES "
                f"environment variable to a comma-separated list "
                f"(e.g. AUTOGEN_ALLOWED_PROVIDER_NAMESPACES=mycompany_agents,mypackage)."
            )

        module = importlib.import_module(module_path)
        component_class = module.__getattribute__(class_name)

        if not is_component_class(component_class):
            raise TypeError("Invalid component class")

        # We need to check the schema is valid
        if not hasattr(component_class, "component_config_schema"):
            raise AttributeError("component_config_schema not defined")

        if not hasattr(component_class, "component_type"):
            raise AttributeError("component_type not defined")

        loaded_config_version = loaded_model.component_version or component_class.component_version
        if loaded_config_version < component_class.component_version:
            try:
                instance = component_class._from_config_past_version(loaded_model.config, loaded_config_version)  # type: ignore
            except NotImplementedError as e:
                raise NotImplementedError(
                    f"Tried to load component {component_class} which is on version {component_class.component_version} with a config on version {loaded_config_version} but _from_config_past_version is not implemented"
                ) from e
        else:
            schema = component_class.component_config_schema  # type: ignore

View on GitHub (pinned to 027ecf0a37)