{"record":{"id":"1eb33d3281ffb74b","repo":"Unity-Technologies/ml-agents","slug":"your-final-lesson-definition-contains-completion-c","errorCode":null,"errorMessage":"Your final lesson definition contains completion_criteria for {parameter_name}.It will be ignored.","messagePattern":"Your final lesson definition contains completion_criteria for (.+?)\\.It will be ignored\\.","errorType":"console","errorClass":"TrainerConfigWarning","httpStatus":null,"severity":"warning","filePath":"ml-agents/mlagents/trainers/settings.py","lineNumber":552,"sourceCode":"    parameter.\n    \"\"\"\n\n    curriculum: List[Lesson]\n\n    @staticmethod\n    def _check_lesson_chain(lessons, parameter_name):\n        \"\"\"\n        Ensures that when using curriculum, all non-terminal lessons have a valid\n        CompletionCriteria, and that the terminal lesson does not contain a CompletionCriteria.\n        \"\"\"\n        num_lessons = len(lessons)\n        for index, lesson in enumerate(lessons):\n            if index < num_lessons - 1 and lesson.completion_criteria is None:\n                raise TrainerConfigError(\n                    f\"A non-terminal lesson does not have a completion_criteria for {parameter_name}.\"\n                )\n            if index == num_lessons - 1 and lesson.completion_criteria is not None:\n                warnings.warn(\n                    f\"Your final lesson definition contains completion_criteria for {parameter_name}.\"\n                    f\"It will be ignored.\",\n                    TrainerConfigWarning,\n                )\n\n    @staticmethod\n    def structure(d: Mapping, t: type) -> Dict[str, \"EnvironmentParameterSettings\"]:\n        \"\"\"\n        Helper method to structure a Dict of EnvironmentParameterSettings class. Meant\n        to be registered with cattr.register_structure_hook() and called with\n        cattr.structure().\n        \"\"\"\n        if not isinstance(d, Mapping):\n            raise TrainerConfigError(\n                f\"Unsupported parameter environment parameter settings {d}.\"\n            )\n        d_final: Dict[str, EnvironmentParameterSettings] = {}\n        for environment_parameter, environment_parameter_config in d.items():","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/settings.py#L534-L570","documentation":"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.","triggerScenarios":"Defining a curriculum where the terminal (last) lesson for a parameter has a completion_criteria block; training then emits this warning during curriculum setup.","commonSituations":"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.","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."],"exampleFix":"// before\nlesson: 2\n  value: 3.0\n  completion_criteria:\n    measure: reward\n    behavior: MyBehavior\n// after\nlesson: 2\n  value: 3.0","handlingStrategy":"try-catch","validationCode":"import yaml\n\ndef validate_curriculum(path):\n    cfg = yaml.safe_load(open(path))\n    for name, behavior in cfg.get(\"behaviors\", {}).items():\n        for param, curriculum in behavior.get(\"curriculum\", {}).items():\n            lessons = curriculum.get(\"lessons\", [])\n            if lessons and \"completion_criteria\" in lessons[-1]:\n                print(f\"warning: last lesson for {param} in {name} has completion_criteria; it will be ignored\")","typeGuard":"def terminal_lesson_has_criteria(lessons: list) -> bool:\n    return bool(lessons) and lessons[-1].get(\"completion_criteria\") is not None","tryCatchPattern":"import warnings\nfrom mlagents.trainers.settings import TrainerConfigWarning\nwith warnings.catch_warnings(record=True) as caught:\n    warnings.simplefilter(\"always\")\n    # load curriculum / start training\n    for w in caught:\n        if issubclass(w.category, TrainerConfigWarning) and \"final lesson\" in str(w.message):\n            print(\"Remove completion_criteria from the terminal lesson.\")","preventionTips":["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."],"tags":["python","ml-agents","curriculum","lesson","config-warning"],"backgroundTag":"ignored-terminal-lesson-criteria","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}