{"record":{"id":"584376c3fbacf6ea","repo":"Unity-Technologies/ml-agents","slug":"the-trainer-config-contains-an-unknown-trainer-typ","errorCode":null,"errorMessage":"The trainer config contains an unknown trainer type {trainer_settings.trainer_type} for brain {brain_name}","messagePattern":"The trainer config contains an unknown trainer type (.+?) for brain (.+?)","errorType":"exception","errorClass":"TrainerConfigError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/trainer/trainer_factory.py","lineNumber":116,"sourceCode":"\n        min_lesson_length = param_manager.get_minimum_reward_buffer_size(brain_name)\n\n        trainer: Trainer = None  # type: ignore  # will be set to one of these, or raise\n\n        try:\n            trainer_type = all_trainer_types[trainer_settings.trainer_type]\n            trainer = trainer_type(\n                brain_name,\n                min_lesson_length,\n                trainer_settings,\n                train_model,\n                load_model,\n                seed,\n                trainer_artifact_path,\n            )\n\n        except KeyError:\n            raise TrainerConfigError(\n                f\"The trainer config contains an unknown trainer type \"\n                f\"{trainer_settings.trainer_type} for brain {brain_name}\"\n            )\n\n        if trainer_settings.self_play is not None:\n            trainer = GhostTrainer(\n                trainer,\n                brain_name,\n                ghost_controller,\n                min_lesson_length,\n                trainer_settings,\n                train_model,\n                trainer_artifact_path,\n            )\n        return trainer\n","sourceCodeStart":98,"sourceCodeEnd":132,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/trainer/trainer_factory.py#L98-L132","documentation":"TrainerFactory._initialize_trainer converts trainer settings and, on KeyError (the trainer_type key not present in its trainer-type-to-class mapping), raises TrainerConfigError stating the trainer type is unknown for the given brain. It is a config-validation error guarding the trainer_type hyperparameter.","triggerScenarios":"Setting trainer_type in the trainer config to anything other than ppo, sac, ghost (self-play) or online_bc; the settings dict lookup raises KeyError and is re-raised as TrainerConfigError with the brain name.","commonSituations":"Typo in YAML like trainer_type: PPO (uppercase) or 'ppo2'; using a trainer type removed in the installed ML-Agents version (e.g. il/behavioral cloning renamed to online_bc); copying community configs for a different ML-Agents release.","solutions":["Set trainer_type to one of the supported values: ppo, sac, or online_bc (or use self_play settings for ghost)","Check spelling and casing in the YAML (must be lowercase)","Verify trainer_type against the schema for your installed mlagents version (mlagents-learn --help shows valid types)","Update ML-Agents if your config targets a newer version with different trainer names"],"exampleFix":"// before (config)\ntrainer_type: PPO2\n// after\ntrainer_type: ppo","handlingStrategy":"validation","validationCode":"VALID = {\"ppo\", \"sac\", \"online_bc\"}\nassert trainer_settings.trainer_type.lower() in VALID, f\"Unknown trainer_type {trainer_settings.trainer_type}\"","typeGuard":"def is_known_trainer_type(settings) -> bool:\n    return str(settings.trainer_type).lower() in {\"ppo\", \"sac\", \"ghost\", \"online_bc\"}","tryCatchPattern":"from mlagents.trainers.exception import TrainerConfigError\ntry:\n    trainer = trainer_factory.initialize_trainer_and_rl_glue(...)\nexcept TrainerConfigError as e:\n    logger.error(f\"Fix your YAML: {e}\")\n    raise SystemExit(1)","preventionTips":["Use lowercase trainer_type values: ppo, sac, online_bc","Validate YAML against trainer_config.schema.json","Check the ML-Agents release notes when migrating configs between versions"],"tags":["python","mlagents","config-validation","trainer-type"],"backgroundTag":"unknown-trainer-type","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}