{"record":{"id":"b44a8d4adac7a6c6","repo":"Unity-Technologies/ml-agents","slug":"trainer-was-unable-to-process-any-of-the-goals-pro","errorCode":null,"errorMessage":"Trainer was unable to process any of the goals provided as input.","messagePattern":"Trainer was unable to process any of the goals provided as input\\.","errorType":"exception","errorClass":"UnityTrainerException","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/torch_entities/networks.py","lineNumber":172,"sourceCode":"        :param inputs: List of Tensors corresponding to a set of obs.\n        \"\"\"\n        encodes = []\n        for idx in self._goal_processor_indices:\n            processor = self.processors[idx]\n            if not isinstance(processor, EntityEmbedding):\n                # The input can be encoded without having to process other inputs\n                obs_input = inputs[idx]\n                processed_obs = processor(obs_input)\n                encodes.append(processed_obs)\n            else:\n                raise UnityTrainerException(\n                    \"The one of the goals uses variable length observations. This use \"\n                    \"case is not supported.\"\n                )\n        if len(encodes) != 0:\n            encoded = torch.cat(encodes, dim=1)\n        else:\n            raise UnityTrainerException(\n                \"Trainer was unable to process any of the goals provided as input.\"\n            )\n        return encoded\n\n\nclass NetworkBody(nn.Module):\n    def __init__(\n        self,\n        observation_specs: List[ObservationSpec],\n        network_settings: NetworkSettings,\n        encoded_act_size: int = 0,\n    ):\n        super().__init__()\n        self.normalize = network_settings.normalize\n        self.use_lstm = network_settings.memory is not None\n        self.h_size = network_settings.hidden_units\n        self.m_size = (\n            network_settings.memory.memory_size","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/torch_entities/networks.py#L154-L190","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Attach at least one valid (fixed-size) goal sensor/observation to the agent","Verify the BehaviorSpec actually contains the goal observations you intended (check space size and number of observations)","If goals are not needed, disable the goal configuration instead of passing an empty list","Review the network configuration (networksettings) that splits observations into goals"],"exampleFix":"// before\ngoals = []  # network created with no goal sensors\n// after\ngoals = [VectorSensor(goal_size=8)]\nnetwork = MultiInputNetwork(goal_specs, ...)","handlingStrategy":"validation","validationCode":"if not goal_specs:\n    raise ValueError(\"At least one goal observation is required when goals are enabled\")","typeGuard":"def has_goals(goal_specs) -> bool:\n    return len(goal_specs) > 0","tryCatchPattern":"try:\n    encoded = network.get_goal_encoding(inputs)\nexcept UnityTrainerException as e:\n    logger.error(f\"No goals processed: {e}\")\n    encoded = torch.zeros((batch, goal_size))","preventionTips":["Enable goal configuration only after attaching goal sensors to agents","Assert non-empty goal observation list before network construction","Log the BehaviorSpec at startup to confirm goals exist"],"tags":["python","mlagents","configuration","empty-input"],"backgroundTag":"no-goal-input-provided","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}