Unity-Technologies/ml-agents · error · UnityAgentsException

Unknown tensorProxy expected as output : {tensor.name}

Error message

Unknown tensorProxy expected as output : {tensor.name}

What it means

TensorApplier.ApplyTensors iterates the model's output tensors and looks each up by name in its internal dictionary of registered output appliers. If the model produced an output tensor whose name was not registered, the applier cannot route it to the agent, so it throws.

Source

Thrown at com.unity.ml-agents/Runtime/Inference/TensorApplier.cs:105

        }

        /// <summary>
        /// Updates the state of the agents based on the data present in the tensor.
        /// </summary>
        /// <param name="tensors"> Enumerable of tensors containing the data.</param>
        /// <param name="actionIds"> List of Agents Ids that will be updated using the tensor's data</param>
        /// <param name="lastActions"> Dictionary of AgentId to Actions to be updated</param>
        /// <exception cref="UnityAgentsException"> One of the tensor does not have an
        /// associated applier.</exception>
        public void ApplyTensors(
            IReadOnlyList<TensorProxy> tensors, IList<int> actionIds, Dictionary<int, ActionBuffers> lastActions)
        {
            for (var tensorIndex = 0; tensorIndex < tensors.Count; tensorIndex++)
            {
                var tensor = tensors[tensorIndex];
                if (!m_Dict.ContainsKey(tensor.name))
                {
                    throw new UnityAgentsException(
                        $"Unknown tensorProxy expected as output : {tensor.name}");
                }
                m_Dict[tensor.name].Apply(tensor, actionIds, lastActions);
            }
        }
    }
}

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Use a model exported by a matching version of ml-agents (re-export with the current trainer) so output tensor names match
  2. Check that the model's outputs correspond to action/recorder tensors the ModelRunner expects
  3. Align com.unity.ml-agents and the ml-agents Python package versions
Defensive patterns

Strategy: validation

Validate before calling

foreach (var outputName in modelOutputTensorNames)
    if (!expectedOutputNames.Contains(outputName))
        throw new InvalidOperationException($"Model has unexpected output tensor: {outputName}");

Try / catch

try { tensorApplier.ApplyTensors(tensors, actionIds, lastActions); }
catch (UnityAgentsException e) when (e.Message.Contains("Unknown tensorProxy expected as output"))
{ Debug.LogError("Model output names don't match this ml-agents version — re-export the model."); }

Prevention

When it happens

Trigger: Running inference with a model whose output tensor names differ from the ones TensorApplier initialized from the agent's behavior parameters (e.g. unexpected auxiliary outputs or an old/new naming convention).

Common situations: Using a model exported by a different ml-agents version with renamed tensor outputs; hand-modified or custom-exported ONNX models with extra/renamed outputs; mixing a newer trainer's model with an older Unity plugin.

Related errors


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