Unity-Technologies/ml-agents · warning · TrainerConfigWarning
Your final lesson definition contains completion_criteria fo
Error message
Your final lesson definition contains completion_criteria for {parameter_name}.It will be ignored. What it means
In settings.py, a curriculum's _check_lesson_chain validates lesson progressions for a (redundant) completion_criteria on the last lesson; by definition the final lesson is never 'completed' into another lesson, so its completion_criteria is pointless. ML-Agents issues a TrainerConfigWarning and ignores it rather than erroring.
Source
Thrown at ml-agents/mlagents/trainers/settings.py:552
parameter.
"""
curriculum: List[Lesson]
@staticmethod
def _check_lesson_chain(lessons, parameter_name):
"""
Ensures that when using curriculum, all non-terminal lessons have a valid
CompletionCriteria, and that the terminal lesson does not contain a CompletionCriteria.
"""
num_lessons = len(lessons)
for index, lesson in enumerate(lessons):
if index < num_lessons - 1 and lesson.completion_criteria is None:
raise TrainerConfigError(
f"A non-terminal lesson does not have a completion_criteria for {parameter_name}."
)
if index == num_lessons - 1 and lesson.completion_criteria is not None:
warnings.warn(
f"Your final lesson definition contains completion_criteria for {parameter_name}."
f"It will be ignored.",
TrainerConfigWarning,
)
@staticmethod
def structure(d: Mapping, t: type) -> Dict[str, "EnvironmentParameterSettings"]:
"""
Helper method to structure a Dict of EnvironmentParameterSettings class. Meant
to be registered with cattr.register_structure_hook() and called with
cattr.structure().
"""
if not isinstance(d, Mapping):
raise TrainerConfigError(
f"Unsupported parameter environment parameter settings {d}."
)
d_final: Dict[str, EnvironmentParameterSettings] = {}
for environment_parameter, environment_parameter_config in d.items():View on GitHub (pinned to 3ecb446f75)
Solutions
- Remove the completion_criteria block from the final lesson in the curriculum YAML.
- If the criteria was meant to gate a real lesson, move it to the second-to-last lesson or add another lesson after it.
- Re-run training; the warning is safe to ignore if you leave it, the criteria simply has no effect.
Example fix
// before
lesson: 2
value: 3.0
completion_criteria:
measure: reward
behavior: MyBehavior
// after
lesson: 2
value: 3.0 Defensive patterns
Strategy: try-catch
Validate before calling
import yaml
def validate_curriculum(path):
cfg = yaml.safe_load(open(path))
for name, behavior in cfg.get("behaviors", {}).items():
for param, curriculum in behavior.get("curriculum", {}).items():
lessons = curriculum.get("lessons", [])
if lessons and "completion_criteria" in lessons[-1]:
print(f"warning: last lesson for {param} in {name} has completion_criteria; it will be ignored") Type guard
def terminal_lesson_has_criteria(lessons: list) -> bool:
return bool(lessons) and lessons[-1].get("completion_criteria") is not None Try / catch
import warnings
from mlagents.trainers.settings import TrainerConfigWarning
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
# load curriculum / start training
for w in caught:
if issubclass(w.category, TrainerConfigWarning) and "final lesson" in str(w.message):
print("Remove completion_criteria from the terminal lesson.") Prevention
- Keep completion_criteria only on non-terminal lessons.
- Template lessons so the final lesson omits criteria by construction.
- Treat TrainerConfigWarning as a config lint failure in CI (warnings-as-errors during config load).
- Review curricula after copy-paste edits to lesson blocks.
When it happens
Trigger: Defining a curriculum where the terminal (last) lesson for a parameter has a completion_criteria block; training then emits this warning during curriculum setup.
Common situations: Copy-pasting lesson definitions so the last lesson inherits a completion_criteria; converting an old curriculum format; auto-generating lessons where all lessons share a criteria template.
Related errors
- There was a problem reading a message in a SideChannel. Plea
- StatsSideChannel should never receive messages.
- agent_id {agent_id} is not present in the DecisionSteps
- agent_id {agent_id} is not present in the TerminalSteps
- The behavior {name} needs a continuous input of dimension {_
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/1eb33d3281ffb74b.
Report an issue: GitHub.