Unity-Technologies/ml-agents · error · TrainerConfigError

Threshold for next lesson cannot be greater than 1 when the

Error message

Threshold for next lesson cannot be greater than 1 when the measure is progress.

What it means

LessonSettings validates that when the lesson `measure` is PROGRESS, the `threshold` for advancing to the next lesson must lie between 0 and 1, because progress is measured as a normalized value in [0, 1]. A threshold above 1.0 is unreachable and raises this error.

Source

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

        PROGRESS: str = "progress"
        REWARD: str = "reward"

    behavior: str
    measure: MeasureType = attr.ib(default=MeasureType.REWARD)
    min_lesson_length: int = 0
    signal_smoothing: bool = True
    threshold: float = attr.ib(default=0.0)
    require_reset: bool = False

    @threshold.validator
    def _check_threshold_value(self, attribute, value):
        """
        Verify that the threshold has a value between 0 and 1 when the measure is
        PROGRESS
        """
        if self.measure == self.MeasureType.PROGRESS:
            if self.threshold > 1.0:
                raise TrainerConfigError(
                    "Threshold for next lesson cannot be greater than 1 when the measure is progress."
                )
            if self.threshold < 0.0:
                raise TrainerConfigError(
                    "Threshold for next lesson cannot be negative when the measure is progress."
                )

    def need_increment(
        self, progress: float, reward_buffer: List[float], smoothing: float
    ) -> Tuple[bool, float]:
        """
        Given measures, this method returns a boolean indicating if the lesson
        needs to change now, and a float corresponding to the new smoothed value.
        """
        # Is the min number of episodes reached
        if len(reward_buffer) < self.min_lesson_length:
            return False, smoothing
        if self.measure == CompletionCriteriaSettings.MeasureType.PROGRESS:

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Set threshold to a fraction between 0 and 1 (e.g. 0.7) when measure is progress.
  2. Switch measure to `reward` or `value` if a large absolute threshold is intended.
  3. Re-normalize thresholds when converting a reward-based curriculum to progress-based.

Example fix

# before
measure: progress
threshold: 5.0

# after
measure: progress
threshold: 0.7
Defensive patterns

Strategy: validation

Validate before calling

for lesson in cfg.get('behavioral_cloning', {}).get('lessons', []):
    if lesson.get('measure') == 'progress' and not (0.0 <= lesson['threshold'] <= 1.0):
        raise ValueError('progress thresholds must be within [0, 1]')

Type guard

def is_valid_progress_threshold(lesson) -> bool:
    return lesson.get('measure') != 'progress' or 0.0 <= lesson.get('threshold', 0) <= 1.0

Try / catch

try:
    config = TrainerSettings.structure(raw)
except TrainerConfigError as e:
    if 'Threshold for next lesson' in str(e):
        print('Use a 0-1 threshold for progress measure')
    raise

Prevention

When it happens

Trigger: Configuring a curriculum lesson with `measure: progress` and `threshold: 5` (or any value > 1.0) in the trainer YAML.

Common situations: Users confuse progress (0-1 normalized) with reward or value measures, which can use arbitrary thresholds, and copy a large threshold from a reward-based curriculum.

Related errors


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