Unity-Technologies/ml-agents · error · TrainerConfigError

A non-terminal lesson does not have a completion_criteria fo

Error message

A non-terminal lesson does not have a completion_criteria for {parameter_name}.

What it means

In a curriculum, every lesson except the last must define a CompletionCriteria so the trainer knows when to advance; only the terminal lesson must omit it. mlagents raises TrainerConfigError when a non-final lesson lacks completion_criteria.

Source

Thrown at ml-agents/mlagents/trainers/settings.py:548

@attr.s(auto_attribs=True)
class EnvironmentParameterSettings:
    """
    EnvironmentParameterSettings is an ordered list of lessons for one environment
    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(

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Add a completion_criteria (with measure and threshold) to every non-final lesson in that parameter's lessons list.
  2. Remove completion_criteria from the final lesson only (it is terminal and any criteria there are ignored with a warning).
  3. Re-order lessons so the lesson without criteria is last.

Example fix

// before
lessons:
  - value: 0.0
  - value: 5.0
    completion_criteria:
      measure: progress
      threshold: 0.5
// after
lessons:
  - value: 0.0
    completion_criteria:
      measure: progress
      threshold: 0.5
  - value: 5.0
Defensive patterns

Strategy: validation

Validate before calling

def validate_curriculum(param_cfg):
    lessons = param_cfg['curriculum']['lessons']
    for i, lesson in enumerate(lessons[:-1]):
        assert 'completion_criteria' in lesson, f'lesson {i} missing completion_criteria'
    assert 'completion_criteria' not in lessons[-1], 'final lesson must not have completion_criteria'

Type guard

def is_terminal_lesson(index, lessons):
    return index == len(lessons) - 1

Try / catch

try:
    config = load_config(path)
except TrainerConfigError as e:
    if 'completion_criteria' in str(e):
        logger.error('Curriculum chain broken: %s', e)

Prevention

When it happens

Trigger: A curriculum parameter has multiple lessons but an intermediate (non-terminal) lesson has no completion_criteria block, e.g. a lesson inserted or criteria deleted when editing the config.

Common situations: Adding a new lesson to the middle of a curriculum and forgetting its criteria; simplifying configs by removing a criteria block; copying a terminal lesson as a template for a mid-curriculum lesson.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02). Data as JSON: /api/errors/b98df33708717c75. Report an issue: GitHub.