{"record":{"id":"b0803871a52e9347","repo":"Unity-Technologies/ml-agents","slug":"failedcheck-message","errorCode":null,"errorMessage":"{failedCheck.Message}","messagePattern":"\\{failedCheck\\.Message\\}","errorType":"exception","errorClass":"UnityAgentsException","httpStatus":null,"severity":"error","filePath":"com.unity.ml-agents/Runtime/Inference/ModelRunner.cs","lineNumber":86,"sourceCode":"            {\n#if SENTIS_VERBOSE\n                m_Verbose = true;\n#endif\n\n                // TODO check w/Alex about verbosity level\n                // D.logEnabled = m_Verbose;\n\n                sentisModel = ModelLoader.Load(model);\n                sentisModelInfo = new SentisModelInfo(sentisModel, deterministicInference);\n\n                var failedCheck = SentisModelParamLoader.CheckModelVersion(\n                    sentisModelInfo\n                );\n                if (failedCheck != null)\n                {\n                    if (failedCheck.CheckType == SentisModelParamLoader.FailedCheck.CheckTypeEnum.Error)\n                    {\n                        throw new UnityAgentsException(failedCheck.Message);\n                    }\n                }\n\n                BackendType executionDevice;\n                // WorkerFactory.Type executionDevice;\n                switch (inferenceDevice)\n                {\n                    case InferenceDevice.ComputeShader:\n                        executionDevice = BackendType.GPUCompute;\n                        break;\n                    case InferenceDevice.PixelShader:\n                        executionDevice = BackendType.GPUPixel;\n                        break;\n                    case InferenceDevice.Burst:\n                        executionDevice = BackendType.CPU;\n                        break;\n                    case InferenceDevice.Default: // fallthrough\n                    default:","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/com.unity.ml-agents/Runtime/Inference/ModelRunner.cs#L68-L104","documentation":"ModelRunner validates the Sentis model with SentisModelParamLoader before creating a worker. If validation produces a failed check of type Error, the raw validation message is rethrown as a UnityAgentsException. This surfaces any model/agent mismatch the loader detected (wrong tensor shapes, sizes, or roles).","triggerScenarios":"Instantiating ModelRunner with a .nn/.onnx model whose input/output tensors do not match the Agent's behavior parameters (vector observation size, action space, continuous vs discrete) — failedCheck.CheckType == Error.","commonSituations":"Swapping a trained model into an agent whose Behavior Parameters were changed after training; using a model trained for a different action space (discrete branch sizes vs continuous action size); loading a corrupted or wrong-format model file.","solutions":["Read failedCheck.Message for the exact mismatch and align the Agent's Behavior Parameters (Vector Observation Space Size, Action Space) with the model's expected tensors","Re-export/retrain the model against the current environment definition (matching observation and action spaces)","Verify the model file is a valid Sentis-compatible .nn/.onnx exported by the same ml-agents version"],"exampleFix":"// before\nBehavior Parameters: Vector Observation Space Size = 42, Continuous Actions = 2 (model expects 168 obs, 3 actions)\n// after\nRe-export the model or set Behavior Parameters to match the model: Vector Observation Space Size = 168, Continuous Actions = 3","handlingStrategy":"validation","validationCode":"var failedCheck = SentisModelParamLoader.CheckModel(sentisModel, sentisModelInfo);\nif (failedCheck != null && failedCheck.CheckType == SentisModelParamLoader.FailedCheck.CheckTypeEnum.Error)\n    throw new InvalidOperationException(\"Model incompatible: \" + failedCheck.Message);","typeGuard":"bool IsModelValid(SentisModelParamLoader.FailedCheck check) =>\n    check == null || check.CheckType != SentisModelParamLoader.FailedCheck.CheckTypeEnum.Error;","tryCatchPattern":"try { var runner = new ModelRunner(model, behaviorParameters, inferenceDevice); }\ncatch (UnityAgentsException e)\n{ Debug.LogError($\"Model rejected: {e.Message}. Align Behavior Parameters with the trained model.\"); }","preventionTips":["Never change Agent Behavior Parameters after training/export without re-exporting the model","Compare model tensor shapes (via Sentis inspection) against Vector Observation/Action space sizes before loading","Export the model with the same ml-agents trainer version used in the Unity project"],"tags":["unity","ml-agents","sentis","model-validation","shape-mismatch"],"backgroundTag":"model-tensor-shape-mismatch","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}