Unity-Technologies/ml-agents · error · TrainerConfigError
The trainer config contains an unknown trainer type {trainer
Error message
The trainer config contains an unknown trainer type {trainer_settings.trainer_type} for brain {brain_name} What it means
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.
Source
Thrown at ml-agents/mlagents/trainers/trainer/trainer_factory.py:116
min_lesson_length = param_manager.get_minimum_reward_buffer_size(brain_name)
trainer: Trainer = None # type: ignore # will be set to one of these, or raise
try:
trainer_type = all_trainer_types[trainer_settings.trainer_type]
trainer = trainer_type(
brain_name,
min_lesson_length,
trainer_settings,
train_model,
load_model,
seed,
trainer_artifact_path,
)
except KeyError:
raise TrainerConfigError(
f"The trainer config contains an unknown trainer type "
f"{trainer_settings.trainer_type} for brain {brain_name}"
)
if trainer_settings.self_play is not None:
trainer = GhostTrainer(
trainer,
brain_name,
ghost_controller,
min_lesson_length,
trainer_settings,
train_model,
trainer_artifact_path,
)
return trainer
View on GitHub (pinned to 3ecb446f75)
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
Example fix
// before (config) trainer_type: PPO2 // after trainer_type: ppo
Defensive patterns
Strategy: validation
Validate before calling
VALID = {"ppo", "sac", "online_bc"}
assert trainer_settings.trainer_type.lower() in VALID, f"Unknown trainer_type {trainer_settings.trainer_type}" Type guard
def is_known_trainer_type(settings) -> bool:
return str(settings.trainer_type).lower() in {"ppo", "sac", "ghost", "online_bc"} Try / catch
from mlagents.trainers.exception import TrainerConfigError
try:
trainer = trainer_factory.initialize_trainer_and_rl_glue(...)
except TrainerConfigError as e:
logger.error(f"Fix your YAML: {e}")
raise SystemExit(1) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The schedule {self.schedule} is invalid.
- The trainer was unable to process any of the provided inputs
- The one of the goals uses variable length observations. This
- Trainer was unable to process any of the goals provided as i
- Visual observation resolution ({width}x{height}) is too smal
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/584376c3fbacf6ea.
Report an issue: GitHub.