Unity-Technologies/ml-agents · error · TrainerConfigError
Threshold for next lesson cannot be negative when the measur
Error message
Threshold for next lesson cannot be negative when the measure is progress.
What it means
When a curriculum lesson uses MeasureType.PROGRESS, the completion threshold represents a fraction of lessons completed and must lie in [0.0, 1.0]. mlagents throws TrainerConfigError during config validation because a negative threshold is meaningless for progress-based advancement.
Source
Thrown at ml-agents/mlagents/trainers/settings.py:485
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:
if progress > self.threshold:
return True, smoothing
if self.measure == CompletionCriteriaSettings.MeasureType.REWARD:
if len(reward_buffer) < 1:View on GitHub (pinned to 3ecb446f75)
Solutions
- Set the threshold to a value between 0.0 and 1.0 (e.g. 0.5 for advancing after 50% of episodes complete).
- If you intended reward-strength-based advancement, change measure to reward and use an appropriate reward threshold.
- Check for stray minus signs from templating or string concatenation when generating configs.
Example fix
// before measure: progress completion_criteria: threshold: -0.2 // after measure: progress completion_criteria: threshold: 0.3
Defensive patterns
Strategy: validation
Validate before calling
def validate_progress_threshold(measure, threshold):
if measure == 'progress' and not (0.0 <= threshold <= 1.0):
raise ValueError('progress threshold must be in [0.0, 1.0], got %r' % threshold) Type guard
def is_valid_threshold(x):
return isinstance(x, (int, float)) and 0.0 <= x <= 1.0 Try / catch
from mlagents.trainers.exception import TrainerConfigError
try:
load_config(path)
except TrainerConfigError as e:
logger.error('Invalid curriculum threshold: %s', e) Prevention
- Keep progress thresholds within 0-1; reserve negative thresholds for reward measures
- Validate curriculum blocks with a linter or unit test before training
- Avoid templating that inserts values without range checks
When it happens
Trigger: A YAML/JSON curriculum defines a lesson with completion_criteria: threshold less than 0.0 while measure: progress (e.g. threshold: -0.5, a typo or copy-paste from a reward/progress-based config).
Common situations: Hand-editing curriculum configs, converting configs between measure types (reward thresholds can be negative, progress cannot), or templated config generation producing bad values.
Related errors
- A non-terminal lesson does not have a completion_criteria fo
- 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 greater than 1 when the
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/3a562e1c3f9bfab7.
Report an issue: GitHub.