Unity-Technologies/ml-agents · error · UnityTrainerException

Trainer was unable to process any of the goals provided as i

Error message

Trainer was unable to process any of the goals provided as input.

What it means

get_goal_encoding raises UnityTrainerException when the list of successfully encoded goal observations is empty, meaning no goal input could be processed. The method requires at least one non-EntityEmbedding goal sensor so it can torch.cat the encodings; with zero encodes there is nothing to concatenate.

Source

Thrown at ml-agents/mlagents/trainers/torch_entities/networks.py:172

        :param inputs: List of Tensors corresponding to a set of obs.
        """
        encodes = []
        for idx in self._goal_processor_indices:
            processor = self.processors[idx]
            if not isinstance(processor, EntityEmbedding):
                # The input can be encoded without having to process other inputs
                obs_input = inputs[idx]
                processed_obs = processor(obs_input)
                encodes.append(processed_obs)
            else:
                raise UnityTrainerException(
                    "The one of the goals uses variable length observations. This use "
                    "case is not supported."
                )
        if len(encodes) != 0:
            encoded = torch.cat(encodes, dim=1)
        else:
            raise UnityTrainerException(
                "Trainer was unable to process any of the goals provided as input."
            )
        return encoded


class NetworkBody(nn.Module):
    def __init__(
        self,
        observation_specs: List[ObservationSpec],
        network_settings: NetworkSettings,
        encoded_act_size: int = 0,
    ):
        super().__init__()
        self.normalize = network_settings.normalize
        self.use_lstm = network_settings.memory is not None
        self.h_size = network_settings.hidden_units
        self.m_size = (
            network_settings.memory.memory_size

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Attach at least one valid (fixed-size) goal sensor/observation to the agent
  2. Verify the BehaviorSpec actually contains the goal observations you intended (check space size and number of observations)
  3. If goals are not needed, disable the goal configuration instead of passing an empty list
  4. Review the network configuration (networksettings) that splits observations into goals

Example fix

// before
goals = []  # network created with no goal sensors
// after
goals = [VectorSensor(goal_size=8)]
network = MultiInputNetwork(goal_specs, ...)
Defensive patterns

Strategy: validation

Validate before calling

if not goal_specs:
    raise ValueError("At least one goal observation is required when goals are enabled")

Type guard

def has_goals(goal_specs) -> bool:
    return len(goal_specs) > 0

Try / catch

try:
    encoded = network.get_goal_encoding(inputs)
except UnityTrainerException as e:
    logger.error(f"No goals processed: {e}")
    encoded = torch.zeros((batch, goal_size))

Prevention

When it happens

Trigger: Calling get_goal_encoding on a network whose goal sensor list is empty, or where every goal processor raised earlier (e.g. all were EntityEmbedding and the earlier error path already fired).

Common situations: Configuring a multi-agent/self-play trainer with goals enabled but no actual goal observations attached to the agent; a behavior spec whose goal-related sensors were misconfigured or removed.

Related errors


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