{"record":{"id":"810642a2acfb8524","repo":"dotnet/machinelearning","slug":"the-runner-metric-manager-is-of-type-metricmanag","errorCode":null,"errorMessage":"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}","messagePattern":"The runner metric manager is of type (.+?) which expected to be of type (.+?) or (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/API/BinaryClassificationExperiment.cs","lineNumber":445,"sourceCode":"                    var loss = metricManager.IsMaximize ? -metric : metric;\n\n                    stopWatch.Stop();\n\n\n                    return new TrialResult<BinaryClassificationMetrics>()\n                    {\n                        Loss = loss,\n                        Metric = metric,\n                        Model = model,\n                        TrialSettings = settings,\n                        DurationInMilliseconds = stopWatch.ElapsedMilliseconds,\n                        Metrics = metrics,\n                        Pipeline = refitPipeline,\n                    };\n                }\n            }\n\n            throw new ArgumentException($\"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}\");\n        }\n\n        public Task<TrialResult> RunAsync(TrialSettings settings, CancellationToken ct)\n        {\n            try\n            {\n                using (var ctRegistration = ct.Register(() =>\n                {\n                    _context?.CancelExecution();\n                }))\n                {\n                    return Task.FromResult(Run(settings));\n                }\n            }\n            catch (Exception ex) when (ct.IsCancellationRequested)\n            {\n                throw new OperationCanceledException(ex.Message, ex.InnerException);\n            }","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/API/BinaryClassificationExperiment.cs#L427-L463","documentation":"The AutoML experiment runner's _metricManager must be an ITrainValidateDatasetManager or ICrossValidateDatasetManager for BinaryClassification trials; if it is any other type, Run throws ArgumentException because the metric/dataset management contract is unfulfillable. This is an internal invariant failure of the AutoML framework.","triggerScenarios":"TrialSettings/Tuner configuration producing a metric manager of an unexpected type — e.g. custom experiment extensions or mismatched AutoML component versions where a different IDatasetManager implementation is injected.","commonSituations":"Mixing Microsoft.ML.AutoML package versions; subclassing/extending experiments and wiring a custom runner whose _metricManager isn't one of the two supported managers.","solutions":["Use a supported Microsoft.ML.AutoML version and avoid mixing AutoML assemblies","Ensure custom experiment/runners set _metricManager to ITrainValidateDatasetManager or ICrossValidateDatasetManager","Report/pin consistent package versions across Microsoft.ML.AutoML and dependents"],"exampleFix":"// before: custom runner with wrong manager\n_metricManager = new MyCustomDatasetManager();\n// after\n_metricManager = new TrainValidateDatasetManager(...); // or CrossValidationDatasetManager","handlingStrategy":"try-catch","validationCode":"// pin and verify AutoML package versions at build time\ndotnet list package --include-transitive | grep Microsoft.ML.AutoML","typeGuard":"null","tryCatchPattern":"try { var r = experiment.Run(trainData, null); } catch (ArgumentException ex) when (ex.Message.Contains(\"runner metric manager\")) { // fix component wiring / package versions, then rerun\n    throw; }","preventionTips":["Don't mix Microsoft.ML.AutoML versions across projects","When extending runners, set _metricManager to a supported manager type","Test experiment startup with a tiny dataset before long runs"],"tags":["automl","internal","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}