{"record":{"id":"1654f7585164873e","repo":"Unity-Technologies/ml-agents","slug":"invalid-trainer-type-val-was-found","errorCode":null,"errorMessage":"Invalid trainer type {val} was found","messagePattern":"Invalid trainer type (.+?) was found","errorType":"validation","errorClass":"TrainerConfigError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/settings.py","lineNumber":722,"sourceCode":"                        val, d_copy[\"trainer_type\"]\n                    )\n                    try:\n                        d_copy[key] = strict_to_cls(\n                            d_copy[key], all_trainer_settings[d_copy[\"trainer_type\"]]\n                        )\n                    except KeyError:\n                        raise TrainerConfigError(\n                            f\"Settings for trainer type {d_copy['trainer_type']} were not found\"\n                        )\n            elif key == \"max_steps\":\n                d_copy[key] = int(float(val))\n                # In some legacy configs, max steps was specified as a float\n            # elif key == \"even_checkpoints\":\n            #     if val:\n            #         d_copy[\"checkpoint_interval\"] = int(d_copy[\"max_steps\"] / d_copy[\"keep_checkpoints\"])\n            elif key == \"trainer_type\":\n                if val not in all_trainer_types.keys():\n                    raise TrainerConfigError(f\"Invalid trainer type {val} was found\")\n            else:\n                d_copy[key] = check_and_structure(key, val, t)\n        return t(**d_copy)\n\n    class DefaultTrainerDict(collections.defaultdict):\n        def __init__(self, *args):\n            # Depending on how this is called, args may have the defaultdict\n            # callable at the start of the list or not. In particular, unpickling\n            # will pass [TrainerSettings].\n            if args and args[0] == TrainerSettings:\n                super().__init__(*args)\n            else:\n                super().__init__(TrainerSettings, *args)\n            self._config_specified = True\n\n        def set_config_specified(self, require_config_specified: bool) -> None:\n            self._config_specified = require_config_specified\n","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/settings.py#L704-L740","documentation":"Thrown while structuring the trainer config dictionary in settings.py: the 'trainer_type' string parsed from the YAML config does not match any registered trainer settings class (it is not a key of the all_trainer_settings registry mapping trainer types like 'ppo' or 'sac' to their TrainerSettings subclasses). It fires at config-load time, before any training starts, and means the typo or unsupported trainer type prevents the behavior's settings from being built.","triggerScenarios":"trainer_type set to a misspelled, mis-cased, or nonexistent value such as 'PPO', 'ppo2', 'imitation', or with trailing whitespace.","commonSituations":"Copying configs from other frameworks or old ML-Agents versions (pre-1.0 used different naming); hand-editing typos; IDE autocomplete inserting wrong values.","solutions":["Use one of the supported values: ppo, sac, poca.","Normalize casing (lowercase) and strip whitespace.","Consult the ML-Agents docs for the version you use to confirm valid trainer types."],"exampleFix":"// before\ntrainer_type: PPO\n// after\ntrainer_type: ppo","handlingStrategy":"validation","validationCode":"tt = cfg.get('trainer_type')\nif tt not in ('ppo', 'sac', 'poca'):\n    raise ValueError(f'Invalid trainer_type: {tt!r}')","typeGuard":"from typing import Literal\ndef is_valid_trainer_type(v) -> 'Literal[\"ppo\",\"sac\",\"poca\"]':\n    return v in ('ppo', 'sac', 'poca')","tryCatchPattern":"from mlagents.trainers.exception import TrainerConfigError\ntry:\n    load_config(path)\nexcept TrainerConfigError as e:\n    if 'Invalid trainer type' in str(e):\n        logger.error('%s - use ppo, sac or poca', e)","preventionTips":["Lowercase all trainer_type strings","Migrate old trainer names when upgrading ML-Agents versions","Use schema-aware YAML editing for autocomplete on allowed values"],"tags":["config","ml-agents"],"backgroundTag":"invalid-enum-value","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}