{"record":{"id":"0be278123e893962","repo":"FoundationAgents/MetaGPT","slug":"model-model-not-found-in-configuration","errorCode":null,"errorMessage":"Model '{model}' not found in configuration","messagePattern":"Model '(.+?)' not found in configuration","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/spo/utils/llm_client.py","lineNumber":38,"sourceCode":"    def __init__(\n        self,\n        optimize_kwargs: Optional[dict] = None,\n        evaluate_kwargs: Optional[dict] = None,\n        execute_kwargs: Optional[dict] = None,\n    ) -> None:\n        self.evaluate_llm = LLM(llm_config=self._load_llm_config(evaluate_kwargs))\n        self.optimize_llm = LLM(llm_config=self._load_llm_config(optimize_kwargs))\n        self.execute_llm = LLM(llm_config=self._load_llm_config(execute_kwargs))\n\n    def _load_llm_config(self, kwargs: dict) -> Any:\n        model = kwargs.get(\"model\")\n        if not model:\n            raise ValueError(\"'model' parameter is required\")\n\n        try:\n            model_config = ModelsConfig.default().get(model)\n            if model_config is None:\n                raise ValueError(f\"Model '{model}' not found in configuration\")\n\n            config = model_config.model_copy()\n\n            for key, value in kwargs.items():\n                if hasattr(config, key):\n                    setattr(config, key, value)\n\n            return config\n\n        except AttributeError:\n            raise ValueError(f\"Model '{model}' not found in configuration\")\n        except Exception as e:\n            raise ValueError(f\"Error loading configuration for model '{model}': {str(e)}\")\n\n    async def responser(self, request_type: RequestType, messages: List[dict]) -> str:\n        llm_mapping = {\n            RequestType.OPTIMIZE: self.optimize_llm,\n            RequestType.EVALUATE: self.evaluate_llm,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/spo/utils/llm_client.py#L20-L56","documentation":"Raised by _load_llm_config when ModelsConfig.default().get(model) returns None (the name is absent from the loaded models registry) or raises AttributeError (the registry itself failed to load, e.g. missing/malformed models config file). Both are converted to this ValueError naming the offending model.","triggerScenarios":"Passing a model name that is not defined in the models configuration file (typo, custom model not registered), or the ModelsConfig source file being absent so .default()/.get fails with AttributeError.","commonSituations":"Misspelled model names; using a private/local model without adding it to the models yaml; upgrading MetaGPT changed the models config location/format so default() cannot load it.","solutions":["Use a model name exactly as defined in the models configuration registry","Add your custom model entry to the models config file and retry","If the error comes from the AttributeError path, verify the models config file exists and is valid YAML at the expected path"],"exampleFix":"# before\nevaluate_kwargs={\"model\": \"gpt4o\"}\n\n# after\nevaluate_kwargs={\"model\": \"gpt-4o\"}","handlingStrategy":"validation","validationCode":"from metagpt.utils.models_config import ModelsConfig\nnames = list(ModelsConfig.default().models.keys()) if hasattr(ModelsConfig.default(), \"models\") else None\nif ModelsConfig.default().get(model) is None:\n    raise ValueError(f\"register '{model}' in models config first\")","typeGuard":"def model_is_registered(model: str) -> bool:\n    from metagpt.utils.models_config import ModelsConfig\n    cfg = ModelsConfig.default()\n    return cfg.get(model) is not None","tryCatchPattern":null,"preventionTips":["Copy model names verbatim from the models config registry","Add custom models to the models yaml before referencing them","If the AttributeError path fires, verify the models config file exists and parses"],"tags":["spo","config","llm","model-registry"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}