{"record":{"id":"569bd88b21061060","repo":"huggingface/smolagents","slug":"unknown-model-class-model-info-class-suppo","errorCode":null,"errorMessage":"Unknown model class '{model_info['class']}'. Supported models: {', '.join(sorted(MODEL_REGISTRY.keys()))}","messagePattern":"Unknown model class '(.+?)'\\. Supported models: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/smolagents/agents.py","lineNumber":1025,"sourceCode":"        }\n        return agent_dict\n\n    @classmethod\n    def from_dict(cls, agent_dict: dict[str, Any], **kwargs) -> \"MultiStepAgent\":\n        \"\"\"Create agent from a dictionary representation.\n\n        Args:\n            agent_dict (`dict[str, Any]`): Dictionary representation of the agent.\n            **kwargs: Additional keyword arguments that will override agent_dict values.\n\n        Returns:\n            `MultiStepAgent`: Instance of the agent class.\n        \"\"\"\n        # Load model\n        model_info = agent_dict[\"model\"]\n        model_class = MODEL_REGISTRY.get(model_info[\"class\"])\n        if model_class is None:\n            raise ValueError(\n                f\"Unknown model class '{model_info['class']}'. \"\n                f\"Supported models: {', '.join(sorted(MODEL_REGISTRY.keys()))}\"\n            )\n        model = model_class.from_dict(model_info[\"data\"])\n        # Load tools\n        tools = []\n        for tool_info in agent_dict[\"tools\"]:\n            tools.append(Tool.from_code(tool_info[\"code\"]))\n        # Load managed agents\n        managed_agents = []\n        for managed_agent_dict in agent_dict[\"managed_agents\"]:\n            agent_class = AGENT_REGISTRY.get(managed_agent_dict[\"class\"])\n            if agent_class is None:\n                raise ValueError(\n                    f\"Unknown agent class '{managed_agent_dict['class']}'. \"\n                    f\"Supported agents: {', '.join(sorted(AGENT_REGISTRY.keys()))}\"\n                )\n            managed_agent = agent_class.from_dict(managed_agent_dict, **kwargs)","sourceCodeStart":1007,"sourceCodeEnd":1043,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/agents.py#L1007-L1043","documentation":"Raised by MultiStepAgent.from_dict when the serialized agent's 'model' entry names a class that is not in MODEL_REGISTRY. from_dict reconstructs an agent from a dict produced by to_dict, and it looks up the model class by name before calling model_class.from_dict. If the class string doesn't exactly match a registered model (e.g. due to a typo, rename, or a custom model that was never registered via MODEL_REGISTRY), deserialization fails.","triggerScenarios":"Calling MultiStepAgent.from_dict(agent_dict) (directly or via from_folder/from_hub) where agent_dict['model']['class'] is not a key in MODEL_REGISTRY, e.g. {'model': {'class': 'OpenAIServerModelX', 'data': {...}}} or a custom model class that wasn't added to MODEL_REGISTRY before serialization.","commonSituations":"Hand-edited or programmatically generated agent dicts; smolagents version drift where model class names changed; loading a pickled/dict agent built around a custom Model subclass without registering it first.","solutions":["Print sorted(MODEL_REGISTRY.keys()) and correct the 'class' string in the dict to exactly match a registered model class name.","If the dict came from a custom model, register that class with MODEL_REGISTRY (MODEL_REGISTRY['MyModel'] = MyModel) before calling from_dict.","Re-serialize the agent with agent.to_dict() using the same smolagents version you load it with to avoid name drift."],"exampleFix":"# before\nagent = MultiStepAgent.from_dict({'model': {'class': 'openai_model', 'data': {...}}, ...})\n\n# after\nfrom smolagents.models import MODEL_REGISTRY\nprint(sorted(MODEL_REGISTRY.keys()))  # e.g. ['InferenceClientModel', 'OpenAIServerModel', ...]\nagent = MultiStepAgent.from_dict({'model': {'class': 'OpenAIServerModel', 'data': {...}}, ...})","handlingStrategy":"validation","validationCode":"from smolagents.models import MODEL_REGISTRY\n\ndef agent_dict_is_loadable(agent_dict: dict) -> bool:\n    return agent_dict['model']['class'] in MODEL_REGISTRY","typeGuard":null,"tryCatchPattern":"try:\n    agent = MultiStepAgent.from_dict(agent_dict)\nexcept ValueError as e:\n    if 'Unknown model class' in str(e):\n        raise SystemExit(f\"Fix model class: {e}\")\n    raise","preventionTips":["Always produce agent dicts via to_dict() in the same smolagents version used for loading.","Register custom model classes in MODEL_REGISTRY before deserializing.","Assert the class key exists in MODEL_REGISTRY before calling from_dict."],"tags":["smolagents","serialization","model-registry","deserialization"],"backgroundTag":"unknown-class-in-registry","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}