{"record":{"id":"7d95a13689491335","repo":"FoundationAgents/MetaGPT","slug":"model-parameter-is-required","errorCode":null,"errorMessage":"'model' parameter is required","messagePattern":"'model' parameter is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/ext/spo/utils/llm_client.py","lineNumber":33,"sourceCode":"\n\nclass SPO_LLM:\n    _instance: Optional[\"SPO_LLM\"] = None\n\n    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)}\")","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/ext/spo/utils/llm_client.py#L15-L51","documentation":"Raised by the SPO LLM client's _load_llm_config when the kwargs dict for one of the three LLM roles (evaluate/optimize/execute) has no 'model' key. The model name is the primary lookup key into ModelsConfig, so it is mandatory for each role-specific config.","triggerScenarios":"Constructing the client with evaluate_kwargs/optimize_kwargs/execute_kwargs dicts that omit 'model', or with None kwargs (None.get would raise earlier, but {} lacks 'model').","commonSituations":"Configuring only some of the three LLMs (e.g. setting optimize_kwargs but leaving evaluate_kwargs as an empty dict); YAML config where the model key was not indented under the right role.","solutions":["Add a 'model' key to every kwargs dict passed for evaluate, optimize, and execute","Use a model name that exists in your models config (see the next error) once the key is present","Check the example SPO config for the exact kwargs structure"],"exampleFix":"# before\nllm = ...evaluate_kwargs={\"temperature\": 0.3}...\n\n# after\nllm = ...evaluate_kwargs={\"model\": \"gpt-4o-mini\", \"temperature\": 0.3}...","handlingStrategy":"validation","validationCode":"for name, kw in ((\"evaluate\", evaluate_kwargs), (\"optimize\", optimize_kwargs), (\"execute\", execute_kwargs)):\n    assert kw and kw.get(\"model\"), f\"{name} kwargs must include 'model'\"","typeGuard":"def kwargs_have_model(kwargs: dict | None) -> bool:\n    return bool(kwargs) and bool(kwargs.get(\"model\"))","tryCatchPattern":null,"preventionTips":["Fill all three kwargs dicts from config with model as a required key","Validate config presence for evaluate/optimize/execute LLMs before constructing the client"],"tags":["spo","config","llm","validation"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}