Unity-Technologies/ml-agents · error · TrainerConfigError
Settings for trainer type {d_copy['trainer_type']} were not
Error message
Settings for trainer type {d_copy['trainer_type']} were not found What it means
After determining trainer_type, the hook looks up matching hyperparameter settings in all_trainer_settings; if hyperparameters were specified but the trainer_type has no corresponding settings class registered, a KeyError is converted to TrainerConfigError.
Source
Thrown at ml-agents/mlagents/trainers/settings.py:711
for key, val in d_copy.items():
if attr.has(type(val)):
# Don't convert already-converted attrs classes.
continue
if key == "hyperparameters":
if "trainer_type" not in d_copy:
raise TrainerConfigError(
"Hyperparameters were specified but no trainer_type was given."
)
else:
d_copy[key] = check_hyperparam_schedules(
val, d_copy["trainer_type"]
)
try:
d_copy[key] = strict_to_cls(
d_copy[key], all_trainer_settings[d_copy["trainer_type"]]
)
except KeyError:
raise TrainerConfigError(
f"Settings for trainer type {d_copy['trainer_type']} were not found"
)
elif key == "max_steps":
d_copy[key] = int(float(val))
# In some legacy configs, max steps was specified as a float
# elif key == "even_checkpoints":
# if val:
# d_copy["checkpoint_interval"] = int(d_copy["max_steps"] / d_copy["keep_checkpoints"])
elif key == "trainer_type":
if val not in all_trainer_types.keys():
raise TrainerConfigError(f"Invalid trainer type {val} was found")
else:
d_copy[key] = check_and_structure(key, val, t)
return t(**d_copy)
class DefaultTrainerDict(collections.defaultdict):
def __init__(self, *args):
# Depending on how this is called, args may have the defaultdictView on GitHub (pinned to 3ecb446f75)
Solutions
- Set trainer_type to one of ppo, sac, or poca (exact lowercase spelling).
- Check for whitespace/casing typos in trainer_type.
- Confirm the ML-Agents version supports the trainer type in your config.
Example fix
// before trainer_type: ppo_old // after trainer_type: ppo
Defensive patterns
Strategy: validation
Validate before calling
VALID = {'ppo', 'sac', 'poca'}
if cfg.get('trainer_type') not in VALID:
raise ValueError(f'trainer_type must be one of {VALID}') Type guard
def is_known_trainer_type(v):
return v in ('ppo', 'sac', 'poca') Try / catch
from mlagents.trainers.exception import TrainerConfigError
try:
load_config(path)
except TrainerConfigError as e:
if 'were not found' in str(e):
logger.error('Check trainer_type spelling: %s', e) Prevention
- Use exact lowercase trainer types: ppo, sac, poca
- Strip whitespace from trainer_type values
- Pin ML-Agents version and verify config against its docs
When it happens
Trigger: A config specifies hyperparameters plus a trainer_type whose settings are absent from all_trainer_settings — typically an invalid/unknown trainer_type string that slipped past earlier checks, or a custom/partial trainer registry.
Common situations: Typos like 'ppo ' (trailing space) or 'PPO' casing in trainer_type; version changes renaming trainer types; edited ML-Agents builds with restricted trainer registries.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Config file could not be found at {abs_path}.
- There was an error decoding Config file from {config_path}.
- Error parsing yaml file. Please check for formatting errors.
- Threshold for next lesson cannot be negative when the measur
- A non-terminal lesson does not have a completion_criteria fo
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/e96d3e53d9bc9a3a.
Report an issue: GitHub.